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


PHP Profile::model方法代码示例

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


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

示例1: 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

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new ProfileField();
     $scheme = get_class(Yii::app()->db->schema);
     if (isset($_POST['ProfileField'])) {
         $model->attributes = $_POST['ProfileField'];
         if ($model->validate()) {
             $sql = 'ALTER TABLE ' . Profile::model()->tableName() . ' ADD `' . $model->varname . '` ';
             $sql .= $this->fieldType($model->field_type);
             if ($model->field_type != 'TEXT' && $model->field_type != 'DATE' && $model->field_type != 'BOOL' && $model->field_type != 'BLOB' && $model->field_type != 'BINARY') {
                 $sql .= '(' . $model->field_size . ')';
             }
             $sql .= ' NOT NULL ';
             if ($model->field_type != 'TEXT' && $model->field_type != 'BLOB' || $scheme != 'CMysqlSchema') {
                 if ($model->default) {
                     $sql .= " DEFAULT '" . $model->default . "'";
                 } else {
                     $sql .= $model->field_type == 'TEXT' || $model->field_type == 'VARCHAR' || $model->field_type == 'BLOB' || $model->field_type == 'BINARY' ? " DEFAULT ''" : ($model->field_type == 'DATE' ? " DEFAULT '0000-00-00'" : " DEFAULT 0");
                 }
             }
             $model->dbConnection->createCommand($sql)->execute();
             $model->save();
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->registerScript();
     $this->render('create', array('model' => $model));
 }
开发者ID:Rudianasaja,项目名称:cycommerce,代码行数:32,代码来源:ProfileFieldController.php

示例3: getDefaultPicture

 /**
  * Gets the default profile picture for a specifc user.
  * @param string $userId The Id of the user to get profile picture. If this is empty, the current user's avatar will be returned.
  * @param string $type The type of picture to return (original, thumb.profile, thumb.feed, thumb.icon)
  * @return array The picture info (path, alt, title, width, height)
  */
 public static function getDefaultPicture($userId = '', $type = 'original')
 {
     if (empty($userId)) {
         $userId = Yii::app()->user->getId();
         if (empty($userId)) {
             return null;
         }
     }
     // Detect user's gender to decide which avatar should be chosen
     $gender = Profile::model()->getFieldInfo($userId, User::PREFIX, 'gender');
     if ($gender['value'] === 'male') {
         $info['path'] = Yii::app()->getBaseUrl(true) . '/files/images/default-avatar-male.jpg';
     } else {
         $info['path'] = Yii::app()->getBaseUrl(true) . '/files/images/default-avatar-female.jpg';
     }
     // Alt and title
     $info['alt'] = $info['title'] = UserModule::t('Default Avatar');
     // Get size
     //Yii::app()->getModule('system'); // Get module 'system'
     $photoTypes = Setting::model()->get('photo_types', array('value'));
     /*var_dump($photoTypes->value);
     		var_dump($photoTypes['value']); die;*/
     $photoTypes = json_decode($photoTypes['value'], true);
     // true indicates that the object will be converted to associative arrays
     if (!isset($photoTypes[$type])) {
         $info['width'] = 160;
         $info['height'] = 160;
     } else {
         $info['width'] = $photoTypes[$type]['width'];
         $info['height'] = $photoTypes[$type]['height'];
     }
     return $info;
 }
开发者ID:redlaw,项目名称:lintinzone,代码行数:39,代码来源:ProfilePicture.php

示例4: actionIndex

 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     switch ($_GET['s']) {
         case 'Author':
             $prof = Profile::model()->with('user', 'AuthAssignment')->findAll();
             $cat = Categories::model()->findAll();
             foreach ($cat as $key => $val) {
                 $rescat[$val->getAttributes()['id']] = $val->getAttributes()['cat_name'];
             }
             foreach ($prof as $key => $val) {
                 $res = $val->getAttributes();
                 $res1 = $val->AuthAssignment->getAttributes();
                 //---<<
                 $resuser = $val->user->getAttributes();
                 if ($res['discipline'] != '') {
                     $res['cat_name'] = implode(',', array_intersect_key($rescat, array_flip(explode(',', $res['discipline']))));
                 }
                 if ($res1['itemname'] == 'Author') {
                     $itog[$key] = array_merge($res, $resuser);
                 }
             }
             $dataProvider = new CArrayDataProvider($itog, array('pagination' => array('pageSize' => Yii::app()->controller->module->user_page_size)));
             break;
         default:
             $dataProvider = new CActiveDataProvider('User', array('criteria' => array('condition' => 'status>' . User::STATUS_BANNED, 'with' => array('AuthAssignment' => array('condition' => 'itemname="Customer"', 'together' => true))), 'pagination' => array('pageSize' => Yii::app()->controller->module->user_page_size)));
             break;
     }
     $this->render('/user/index', array('dataProvider' => $dataProvider));
 }
开发者ID:rahmanjis,项目名称:dipstart-development,代码行数:32,代码来源:DefaultController.php

示例5: actionDelete

 public function actionDelete($id)
 {
     $profile = Profile::model()->findByPk($id);
     $profile->delete();
     $user = User::model()->findByPk($id);
     $user->delete();
     $ccuc = CcucUserCompany::model()->deleteAll('ccuc_user_id =:id', array(':id' => $id));
 }
开发者ID:dbrisinajumi,项目名称:d2company,代码行数:8,代码来源:CustomersController.php

示例6: handleBeginRequest

 public function handleBeginRequest($event)
 {
     $loginUserId = Yii::app()->user->getId();
     if ($loginUserId) {
         $time = date("Y-m-d H:i:s");
         Profile::model()->updateByPk($loginUserId, array('LastActivity' => $time));
     }
 }
开发者ID:brahmajiayatas,项目名称:getweiss,代码行数:8,代码来源:LastActivity.php

示例7: isBlogWriter

 public function isBlogWriter()
 {
     $p = Profile::model()->findbypk(Yii::app()->user->id);
     if (isset($p->blog_writer) and $p->blog_writer == 1) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:laptopsr,项目名称:miinus,代码行数:9,代码来源:BlogController.php

示例8: delete

 /**
  * @test
  */
 public function delete()
 {
     $model = $this->users('user');
     // suppression en cascade de l'entrée associée dans la table "profile"
     $this->assertEquals(1, Profile::model()->count('user_id = ' . $model->id));
     $this->assertTrue($model->delete());
     $this->assertEquals(0, Profile::model()->count('user_id = ' . $model->id));
     // @todo Ajouter des tests pour AuthAssignment
 }
开发者ID:ChristopheBrun,项目名称:hLib,代码行数:12,代码来源:UserTestBase.php

示例9: delete

 public function delete()
 {
     // Try create column name
     if (Profile::model()->columnExists($this->profileField->internal_name)) {
         $sql = "ALTER TABLE profile DROP `" . $this->profileField->internal_name . "_hide_year`;";
         $this->profileField->dbConnection->createCommand($sql)->execute();
     }
     return parent::delete();
 }
开发者ID:VasileGabriel,项目名称:humhub,代码行数:9,代码来源:Birthday.php

示例10: save

 /**
  * Saves this Profile Field Type
  */
 public function save()
 {
     $columnName = $this->profileField->internal_name;
     // Try create column name
     if (!Profile::model()->columnExists($columnName)) {
         $sql = "ALTER TABLE profile ADD `" . $columnName . "` VARCHAR(255);";
         $this->profileField->dbConnection->createCommand($sql)->execute();
     }
     parent::save();
 }
开发者ID:ahdail,项目名称:humhub,代码行数:13,代码来源:ProfileFieldTypeSelect.php

示例11: beforeConfirm

 protected function beforeConfirm()
 {
     //delete old email identity here
     $this->dbConnection->createCommand('DELETE FROM user_identity WHERE type = "' . Identity::TYPE_EMAIL . '" AND id != "' . $this->identity->id . '"' . ' AND user_id = "' . $this->identity->user_id . '"')->execute();
     //updating profile
     $confirmatingEmail = $this->identity->identity;
     $profile = Profile::model()->findByPk($this->identity->user_id);
     $profile->email = $confirmatingEmail;
     $profile->save();
     return true;
 }
开发者ID:vasiliy-pdk,项目名称:aes,代码行数:11,代码来源:ReplaceEmailConfirmation.php

示例12: expiration

 public function expiration()
 {
     if (!$this->hasErrors('username')) {
         //    		$user=User::model()->find('username=:name and id <> :id',array(':name'=>$this->username,'id'=>$this->id));
         $result = Profile::model()->findByPk($this->id);
         if ($result) {
             if ($result['ExpirationDate']) {
                 $this->addError('username', '该帐号已过期');
             }
         }
     }
 }
开发者ID:zwq,项目名称:unpei,代码行数:12,代码来源:UserLogin.php

示例13: beforeLogout

 /**
  * @return bool
  * @throws CDbException
  */
 public function beforeLogout()
 {
     User::model()->updateByPk(Yii::app()->user->id, array('status' => '0'));
     $profile = Profile::model()->find('user_id=:uid', array(':uid' => Yii::app()->user->id));
     $time = time() - $profile->last_visit_time;
     $omin = floor($time / 60);
     $osec = $time % 60;
     $otime = $osec > 50 ? $omin + 1 : $omin;
     $profile->online_time = $profile->online_time + $otime;
     $profile->save();
     return true;
 }
开发者ID:GsHatRed,项目名称:Yiitest,代码行数:16,代码来源:AuthWebUser.php

示例14: actionAjaxposts

 public function actionAjaxposts($term)
 {
     if (Yii::app()->request->isAjaxRequest) {
         $criteria = new CDbCriteria();
         $criteria->select = 'user_id, post';
         $criteria->condition = "post LIKE '{$term}%'";
         $criteria->group = 'post';
         $criteria->order = 'post ASC';
         $items = CHtml::listData(Profile::model()->findAll($criteria), 'user_id', 'post');
         echo CJSON::encode($items);
         Yii::app()->end();
     }
 }
开发者ID:kuzmina-mariya,项目名称:happy-end,代码行数:13,代码来源:PeopleController.php

示例15: checkGroupAccess

 protected function checkGroupAccess($itemName, $userId, $params)
 {
     $user = Yii::app()->getUser();
     if (!$user->isGuest) {
         $ugroups = Profile::model()->with('groups')->findByPk($userId);
         foreach ($ugroups->groups as $group) {
             if (parent::checkAccess($itemName, $group->id, $params)) {
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:Rudianasaja,项目名称:cycommerce,代码行数:13,代码来源:CachedDbAuthManager.php


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