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)))); }
/** * 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)); }
/** * 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; }
/** * 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)); }
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)); }
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)); } }
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; } }
/** * @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 }
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(); }
/** * 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(); }
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; }
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', '该帐号已过期'); } } } }
/** * @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; }
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(); } }
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; }
public function actionUpdate($id) { $model = $this->loadModel($id, $this->modelName); //$model=$this->loadModel(); $profile = $model->profile; $gprofile = Profile::model()->with('groups')->findbyPk($model->id); $profile->group_id = $gprofile->groups; $this->performAjaxValidation(array($model, $profile), 'staff-form'); if (isset($_POST['Staff'])) { //$model->attributes=$_POST['Staff']; $model->status = $_POST['Staff']['status']; //$profile->attributes=$_POST['Profile']; $profile->branch_id = $_POST['Profile']['branch_id']; if ($model->validate() && $profile->validate()) { $old_password = Staff::model()->notsafe()->findByPk($model->id); /*if ($old_password->password!=$model->password) { $model->password=PasswordHelper::hashPassword($model->password); $model->activkey=PasswordHelper::hashPassword(microtime().$model->password); }*/ $model->save(); $profile->save(); $criteria = new CDbCriteria(); $criteria->condition = 'profile_id=:profile_id'; $criteria->params = array(':profile_id' => $model->id); UserGroup::model()->deleteAll($criteria); if (!empty($_POST['Profile']['group_id'])) { foreach ($_POST['Profile']['group_id'] as $groupid) { $userGroup = new UserGroup(); $userGroup->profile_id = $model->id; $userGroup->group_id = $groupid; $userGroup->save(); } } if (Yii::app()->getRequest()->getIsAjaxRequest()) { $this->renderPartial('_view', array('model' => $model, 'profile' => $profile), false, true); Yii::app()->end(); } $this->redirect(array('view', 'id' => $model->id)); } else { $profile->validate(); } } if (Yii::app()->getRequest()->getIsAjaxRequest()) { $this->renderPartial('_update', array('model' => $model, 'profile' => $profile), false, true); Yii::app()->end(); } $this->render('update', array('model' => $model, 'profile' => $profile)); }
/** * Runs 4.2.1 migration script * Asserts that guest profile is properly deleted and recreated with correct id. * Asserts that user with missing profile is given a profile with correctly set attributes */ public function testMigrationScript() { // ensure test user doesn't have a profile $userWithoutProfile = User::model()->findByAttributes(array('username' => 'test')); $badProfile = $userWithoutProfile->profile; $this->assertEquals(Profile::GUEST_PROFILE_USERNAME, $badProfile->username); // run guest profile fix migration script $command = Yii::app()->basePath . '/yiic runmigrationscript ' . 'migrations/pending/1410382532-guest-profile-fix.php'; $return_var; $output = array(); X2_TEST_DEBUG_LEVEL > 1 && print_r(exec($command, $return_var, $output)); X2_TEST_DEBUG_LEVEL > 1 && print_r($return_var); X2_TEST_DEBUG_LEVEL > 1 && print_r($output); // ensure that guest profile has correct id $guestProfile = Profile::model()->findByPk(-1); $this->assertNotEquals(null, $guestProfile); $this->assertEquals(Profile::GUEST_PROFILE_USERNAME, $guestProfile->username); // ensure that user which formerly had no profile now has a profile $userWithoutProfile = User::model()->findByAttributes(array('username' => 'test')); $this->assertNotEquals(null, $userWithoutProfile->profile); // ensure that test user profile has correctly set attributes $newProfile = $userWithoutProfile->profile; $newProfileAttributes = $newProfile->getAttributes(); $this->assertEquals($userWithoutProfile->username, $userWithoutProfile->profile->username); $this->assertEquals($userWithoutProfile->firstName . ' ' . $userWithoutProfile->lastName, $userWithoutProfile->profile->fullName); $this->assertEquals($userWithoutProfile->emailAddress, $userWithoutProfile->profile->emailAddress); $this->assertEquals($userWithoutProfile->id, $userWithoutProfile->profile->id); $this->assertEquals(1, $userWithoutProfile->profile->status); $this->assertEquals(1, $userWithoutProfile->profile->allowPost); // delete test user profile and create a new profile in the way that it would be created // by actionCreate () in the user controller and ensure that it's attributes match those // of the profile created by the migration script $newProfile->delete(); $profile = new Profile(); $profile->fullName = $userWithoutProfile->firstName . " " . $userWithoutProfile->lastName; $profile->username = $userWithoutProfile->username; $profile->allowPost = 1; $profile->emailAddress = $userWithoutProfile->emailAddress; $profile->status = $userWithoutProfile->status; $profile->id = $userWithoutProfile->id; $profile->save(); $this->assertEquals($newProfileAttributes, $profile->getAttributes()); }
/** * Load configuration that cannot be put in config/main */ public function beginRequest() { $prof=Profile::model()->findByPk(Yii::app()->user->getId()); if (isset($prof->language)) $this->owner->language=$prof->language; else{ $adminProf=ProfileChild::model()->findByPk(1); $this->owner->language=$adminProf->language; } if(isset($prof->timeZone) && $prof->timeZone!='') date_default_timezone_set($prof->timeZone); $adminProf=ProfileChild::model()->findByAttributes(array('username'=>'admin')); $logo=Media::model()->findByAttributes(array('associationId'=>$adminProf->id,'associationType'=>'logo')); if(isset($logo)){ $this->owner->params->logo=$logo->fileName; } $admin = CActiveRecord::model('Admin')->findByPk(1); $this->owner->params->currency = $admin->currency; }
public function actionSendMail() { date_default_timezone_set('UTC'); $startdate = date('Y-m-d H:i:s', strtotime('+1 hours')); $enddate = date('Y-m-d H:i:s', strtotime('+2 hours 1 minute')); $Poses = Pos::model()->findAll(array('select' => '*', 'condition' => 'date > "' . $startdate . '" and date < "' . $enddate . '"')); $users = User::Model()->findAll(array('select' => '*')); $subject = 'POS Timer Alert'; foreach ($Poses as $pos) { $message = 'The ' . $pos->type . ' in ' . $pos->location . ' is due out of reinforced at ' . $pos->date . PHP_EOL; foreach ($users as $user) { $profiles = Profile::model()->findByPk($user->id); if ($profiles->subscribe) { $email = $user->email; echo $email . ' ' . $subject . ' ' . $message; UserModule::sendMail($email, $subject, $message); } } } }
public function run($args) { $companies = Company::model()->findAll('frozen=:p', array(':p' => '0')); foreach ($companies as $company) { Company::setActive($company); Yii::app()->language = Company::getLanguage(); User::model()->refreshMetaData(); AuthAssignment::model()->refreshMetaData(); ProfileField::model()->refreshMetaData(); Profile::model()->refreshMetaData(); Zakaz::model()->refreshMetaData(); ZakazParts::model()->refreshMetaData(); Events::model()->refreshMetaData(); Templates::model()->refreshMetaData(); Emails::model()->refreshMetaData(); self::executor(); self::manager(); self::send_deffered_emails(); } }
/** * Lists all models. */ public function actionIndex() { switch ($_GET['s']) { case 'Author': $prof = Profile::model()->with('user', 'AuthAssignment')->findAll(); // $prof=Profile::model()->findAll(); //echo '$prof(0)='; //var_dump($prof); //die('$prof(0)='.var_dump($prof)); //echo '$count(prof)='.count($prof); //$cat=Categories::model()->findAll(); //foreach($cat as $key=>$val) $rescat[$val->getAttributes()['id']]=$val->getAttributes()['cat_name']; $itog = array(); foreach ($prof as $key => $val) { //echo $val['user_id'].' '; $res = $val->getAttributes(); if ($res1 = $val->AuthAssignment) { $res1 = $val->AuthAssignment->getAttributes(); } // Непонятное место, без условия бывает глючит ---<< if ($res['discipline'] != '') { $res['cat_name'] = implode(',', array_intersect_key(array(), array_flip(explode(',', $res['discipline'])))); } if ($res1['itemname'] == 'Author') { $resuser = array(); $user = User::model()->findByPk($val->user_id); $resuser = $user->getAttributes(); $resuser = $val->user->getAttributes(); $itog[$user->id] = 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)); }
public function actionSend() { $model = new Emails(); $this->_prepairJson(); $orderId = $this->_request->getParam('orderId'); $typeId = $this->_request->getParam('typeId'); $back = $this->_request->getParam('back'); $cost = $this->_request->getParam('cost'); $order = Zakaz::model()->findByPk($orderId); $arr_type = array(Emails::TYPE_18, Emails::TYPE_19, Emails::TYPE_20, Emails::TYPE_21, Emails::TYPE_22, Emails::TYPE_23, Emails::TYPE_24); if (in_array($typeId, $arr_type)) { $user = User::model()->findByPk($order->executor); } else { $user = User::model()->findByPk($order->user_id); } $model->to_id = $user->id; $profile = Profile::model()->findAll("`user_id`='{$user->id}'"); $rec = Templates::model()->findAll("`type_id`='{$typeId}'"); $title = $rec[0]->title; $model->name = $profle->firstname; if (strlen($model->name) < 2) { $model->name = $user->username; } $model->login = $user->username; $model->num_order = $orderId; $model->page_order = 'http://' . $_SERVER['SERVER_NAME'] . '/project/chat?orderId=' . $orderId; $model->message = $rec[0]->text; $model->price_order = $cost; $this->sum_order = $cost; $model->sendTo($user->email, $rec[0]->text, $typeId); $model->save(); /* if (!isset($back)) $back = 'index'; $this->render($back, [ 'model'=>$model ]); */ }
echo '<td>' . $rivi[1] . '</td>'; echo '<td>' . $rivi[2] . '</td>'; echo '<td>' . $rivi[3] . '</td>'; echo '<td>' . $rivi[4] . '</td>'; echo '<td>' . $rivi[5] . '</td>'; echo '<td>' . $rivi[6] . '</td>'; echo '<td>' . $rivi[7] . '</td>'; echo '<td>' . $rivi[8] . '</td>'; echo '</tr>'; } echo '</table> </div>'; $criteria = new CDbCriteria(); $criteria->select = " user_id "; $criteria->condition = " user_id IN\n\t\t( SELECT myyja_id FROM provisiot \n\t\tWHERE vuosi='" . date("Y", strtotime($thisYear . '-' . $thisMonth)) . "' \n\t\tAND kuukausi='" . (int) date("n", strtotime($thisYear . '-' . $thisMonth)) . "'\n\t\t)\n\t\tAND y_tunnus='' \n\t"; $ytmat = Profile::model()->findAll($criteria); echo '<h3>Y-tunnuksettomat</h3>'; echo ' <div class="table-responsive"> <table class="table"> <tr> <th>Etunimi</th> <th>Sukunimi</th> <th>Tilinumero</th> <th>Alv velvollinen</th> <th>Y-tunnus</th> <th>Maksettava provisio</th> <th>ALV</th> <th>Linkki raporttiin</th> <th>Maksun kuittaus</th> </tr>
?> </div> <!-- Box de Essays Asignados --> <?php $this->beginWidget('yiiwheels.widgets.box.WhBox', array('title' => 'Estudiantes Asignados al Essay', 'headerIcon' => 'icon-th-list')); ?> <?php $dataProvider = new CActiveDataProvider('Students', array('criteria' => array('condition' => 'EXISTS (SELECT * FROM essays_has_cruge_user WHERE students_id = id AND essays_id= :id)', 'params' => array(':id' => $model->id_essays)))); $this->widget('yiiwheels.widgets.grid.WhGridView', array('fixedHeader' => true, 'headerOffset' => 40, 'type' => 'striped', 'dataProvider' => $dataProvider, 'responsiveTable' => true, 'template' => "{items}", 'columns' => array('id', array('header' => 'Nº de Identidad', 'value' => '$data->profile->identification'), array('name' => 'Nombre', 'value' => function ($data, $row) { return Profile::model()->nombreApellido($data->profile->firstname, $data->profile->secondname, $data->profile->lastname1, $data->profile->lastname2); }), array('header' => 'Sexo', 'value' => function ($data, $row) { return Profile::model()->validarSexo($data->profile->sex); }, 'type' => 'raw'), array('header' => 'Correo', 'value' => '$data->profile->email'), array('header' => 'Status', 'type' => 'raw', 'value' => function ($data, $row) { return Profile::model()->validarStatus($data->profile->cruge_user_iduser); }), array('header' => '', 'type' => 'raw', 'value' => "TbHtml::submitButton('Remover',array(\n 'submit'=>array('remove','id'=>" . '$data->id' . "),\n\t\t\t\t\t\t'params'=>array('idx'=>{$model->id_essays}),\n\t\t\t\t\t\t'confirm'=>'Desea remover al estudiante del Essay?',\n 'color'=>TbHtml::BUTTON_COLOR_DANGER,\n 'size'=>TbHtml::BUTTON_SIZE_MINI,\n ))")))); ?> <?php $this->endWidget(); ?> <!-- End Box de Essays Asignados --> <script> $(document).ready(function() { $("#ocultarAdd").click(function(event) { event.preventDefault(); $("#informacion").hide("slow"); $("#ocultarAdd").hide(); $("#mostrarAdd").show();
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'index' page. */ public function actionDelete() { if (Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $model = $this->loadModel(); $profile = Profile::model()->findByPk($model->id); $profile->delete(); $model->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_POST['ajax'])) { $this->redirect(array('/user/admin')); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }
public function testHideDuplicates() { // Hiding duplicates shouldn't delete any contacts Yii::app()->params->adminProf = Profile::model()->findByPk(1); $contact = $this->contacts('contact1'); $this->assertEquals(8, $contact->countDuplicates()); $duplicates = $contact->getDuplicates(true); $this->assertEquals(8, count($duplicates)); $newDuplicates = $contact->getDuplicates(true); $contact->hideDuplicates(); $this->assertEquals(0, $contact->countDuplicates()); $this->assertEquals(8, count($newDuplicates)); // Spot check the fields of one of the duplicates $dupeContact = $this->contacts('contact2'); $this->assertEquals(1, $dupeContact->dupeCheck); $this->assertEquals(0, $dupeContact->visibility); $this->assertEquals('Anyone', $dupeContact->assignedTo); }
foreach ($u as $data) { $o = $this->ordersDataForProvisionEdellinen($data->id, $thisYear, $thisMonth); foreach ($o as $ord) { $v = date("Y-m-d", strtotime($ord->maksettu_pvm . " +14 day")); $ord->hinta = $this->hintaLaske($ord, 0.3); if ($v > date("Y-m-d")) { } elseif ($v <= date("Y-m-d") and !isset($maksetutE[$ord->id])) { $maksamattomatE[$ord->id] = $ord->hinta; } } } // Muut myyjat $u = User::model()->findAll(" paa_myyja='" . $id . "' "); foreach ($u as $uu) { if (isset($uu->id)) { $p = Profile::model()->findByPk($uu->id); $criteria = new CDbCriteria(); $criteria->order = " id DESC "; $criteria->condition = " myyjaID='" . $uu->id . "' "; $u = User::model()->findAll($criteria); foreach ($u as $data) { $o = $this->ordersDataForProvisionEdellinen($data->id, $thisYear, $thisMonth); foreach ($o as $ord) { $v = date("Y-m-d", strtotime($ord->maksettu_pvm . " +14 day")); $ord->hinta = $this->hintaLaske($ord, 0.1); if ($v > date("Y-m-d")) { } elseif ($v <= date("Y-m-d") and !isset($maksetutE[$ord->id])) { $maksamattomatE[$ord->id] = $ord->hinta; } } }
public function actionDeleteAction() { if (isset($_POST['id'])) { $id = $_POST['id']; $action = Actions::model()->findByPk($id); $profile = Profile::model()->findByAttributes(array('username' => $action->assignedTo)); if (isset($profile)) { $profile->deleteGoogleCalendarEvent($action); } // update action in Google Calendar if user has a Google Calendar X2Model::model('Events')->deleteAllByAttributes(array('associationType' => 'Actions', 'type' => 'calendar_event', 'associationId' => $action->id)); $action->delete(); } }
<div class="scrollItem" data-id="scroll-<?php echo $model->id; ?> "> <?php echo Profile::model()->getUserAvatar($model->uid, array('class' => 'left roundSection', 'style' => 'width:50px;padding:10px;'), 50); ?> <span style="color:red;font-weight:bold;"><?php echo $model->title; ?> </span> <?php echo UtilHelper::strSlice(str_replace(' ', '', strip_tags($model->content)), 0, 50); ?> </div>
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'index' page. */ public function actionDelete() { if (Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $model = $this->loadModel(); $profile = Profile::model()->findByPk($model->id); $roles = Roles::model()->findByPk($model->id); $transaction = Yii::app()->db->beginTransaction(); try { // поиск и сохранение — шаги, между которыми могут быть выполнены другие запросы, // поэтому мы используем транзакцию, чтобы удостовериться в целостности данных $profile->delete(); $model->delete(); $roles->delete(); $transaction->commit(); } catch (Exception $e) { $transaction->rollback(); } // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_POST['ajax'])) { $this->redirect(array('/user/admin')); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }