Inheritance: extends TActiveRecord
Example #1
0
 function test_same_data_returns_same_object()
 {
     $criteria = new TActiveRecordCriteria('username = ?', 'admin');
     $finder = new UserRecord();
     $finder->OnCreateCommand[] = array($this, 'logger');
     $finder->OnExecuteCommand[] = array($this, 'logger');
     $user1 = $finder->find($criteria);
     //var_dump($user1);
     //var_dump(UserRecord::finder()->find($criteria));
 }
Example #2
0
 function test_Create_new_user_returns_true()
 {
     $user = new UserRecord();
     $user->username = '******';
     $user->password = md5('asd');
     $user->email = 'asdasd';
     $user->first_name = 'wei';
     $user->last_name = 'zhuo';
     $this->assertTrue($user->save());
     $user->password = md5('more');
     $this->assertTrue($user->save());
     $check = UserRecord::finder()->findByPk('hello');
     $this->assertSameUser($user, $check);
     $this->assertTrue($user->delete());
 }
Example #3
0
 public function onLoad($param)
 {
     date_default_timezone_set('Europe/Berlin');
     $this->setUserStartId($this->user->getStartNode($this->user->getUserId($this->user->Name), "tm_activity"));
     if (!$this->isPostBack && !$this->isCallback) {
         $this->edidta_activity_type->DataSource = PFH::build_SQLPullDown(ActivityTypeRecord::finder(), "ta_activity_type", array("idta_activity_type", "act_type_name"));
         $this->edidta_activity_type->dataBind();
         $this->ttedidtt_ziele->DataSource = PFH::build_SQLPullDown(TTZieleRecord::finder(), "tt_ziele", array("idtt_ziele", "ttzie_name"));
         $this->ttedidtt_ziele->dataBind();
         //los interfaces input
         $this->ttedidtm_inoutput->DataSource = PFH::build_SQLPullDown(ActivityInoutputView::finder(), "vv_activity_inoutput", array("idtm_inoutput", "ino_name"), "ino_link_type=0");
         $this->ttedidtm_inoutput->dataBind();
         //los interfaces
         $this->Iedidta_inoutput_type->DataSource = PFH::build_SQLPullDown(InoutputTypeRecord::finder(), "ta_inoutput_type", array("idta_inoutput_type", "ino_type_name"));
         $this->Iedidta_inoutput_type->dataBind();
         $Usersql = "SELECT idtm_user, user_name FROM tm_user";
         $Userdata = PFH::convertdbObjectArray(UserRecord::finder()->findAllBySql($Usersql), array("idtm_user", "user_name"));
         $this->idtm_user->DataSource = $Userdata;
         $this->idtm_user->dataBind();
         $this->loadBerechtigung();
         $this->CCProtokollDetailGroupListPageSize->DataSource = array(5 => "5", 10 => "10", 15 => "15", 20 => "20");
         $this->CCProtokollDetailGroupListPageSize->dataBind();
         $this->CCProtokollDetailGroupListPageSize->Text = "5";
         $this->CBAufgabeDone->DataSource = $this->auf_done;
         $this->CBAufgabeDone->dataBind();
         $this->CBidta_organisation_art->DataSource = $this->idta_organisation_art;
         $this->CBidta_organisation_art->dataBind();
         $data = array(0 => "Normalfolge(E/A)", 1 => "Anfangsfolge(A/A)", 2 => "Sprungfolge(A/E)", 3 => "Endfolge(E/E)");
         $this->edactact_type->DataSource = $data;
         $this->edactact_type->dataBind();
         $this->getPage()->getClientScript()->registerEndScript('XACTCF', "constructCollapsableFieldsets();");
         $this->generateZeitVerlaufImage(0);
     }
 }
Example #4
0
 public function onInit($param)
 {
     parent::onInit($param);
     //Globale definition f�r dieses Dokument
     $this->finder = StrukturRecord::finder();
     $this->MASTERRECORD = new StrukturRecord();
     if (!$this->isPostBack && !$this->isCallback) {
         switch ($this->Request['modus']) {
             case 0:
                 $sql = "SELECT idta_struktur_type, struktur_type_name FROM ta_struktur_type";
                 $data = PFH::convertdbObjectArray(StrukturTypeRecord::finder()->findAllBySql($sql), array("idta_struktur_type", "struktur_type_name"));
                 $this->idta_struktur_type->DataSource = $data;
                 $this->idta_struktur_type->dataBind();
                 $HRKEYTest = new PFHierarchyPullDown();
                 $HRKEYTest->setStructureTable("tm_struktur");
                 $HRKEYTest->setRecordClass(StrukturRecord::finder());
                 $HRKEYTest->setPKField("idtm_struktur");
                 $HRKEYTest->setField("struktur_name");
                 $HRKEYTest->letsrun();
                 $this->parent_idtm_struktur->DataSource = $HRKEYTest->myTree;
                 $this->parent_idtm_struktur->dataBind();
                 $this->idtm_stammdaten->DataSource = PFH::build_SQLPullDown(StammdatenRecord::finder(), "tm_stammdaten", array("idtm_stammdaten", "stammdaten_name"));
                 $this->idtm_stammdaten->dataBind();
                 break;
             case 1:
                 $sql = "SELECT idta_struktur_type, struktur_type_name FROM ta_struktur_type";
                 $data = PFH::convertdbObjectArray(StrukturTypeRecord::finder()->findAllBySql($sql), array("idta_struktur_type", "struktur_type_name"));
                 $this->edidta_struktur_type->DataSource = $data;
                 $this->edidta_struktur_type->dataBind();
                 if ($this->Request[$this->primarykey] != 1) {
                     $HRKEYTest = new PFHierarchyPullDown();
                     $HRKEYTest->setStructureTable("tm_struktur");
                     $HRKEYTest->setRecordClass(StrukturRecord::finder());
                     $HRKEYTest->setPKField("idtm_struktur");
                     $HRKEYTest->setField("struktur_name");
                     $HRKEYTest->letsrun();
                     $data = $HRKEYTest->myTree;
                 } else {
                     $data = array();
                     $data[0] = "START";
                 }
                 $this->edparent_idtm_struktur->DataSource = $data;
                 $this->edparent_idtm_struktur->dataBind();
                 $this->fillValues($this->getSelected($this->Request[$this->primarykey]));
                 $this->edidtm_stammdaten->DataSource = PFH::build_SQLPullDown(StammdatenRecord::finder(), "tm_stammdaten", array("idtm_stammdaten", "stammdaten_name"));
                 $this->edidtm_stammdaten->dataBind();
                 $Usersql = "SELECT idtm_user, user_name FROM tm_user";
                 $Userdata = PFH::convertdbObjectArray(UserRecord::finder()->findAllBySql($Usersql), array("idtm_user", "user_name"));
                 $this->idtm_user->DataSource = $Userdata;
                 $this->idtm_user->dataBind();
                 $this->loadBerechtigung();
                 break;
             default:
                 break;
         }
         $this->viewPanel->ActiveViewIndex = $this->Request['modus'];
         $this->StrukturStammdatenGroupContainer->RCedidtm_struktur->Text = $this->Request[$this->primarykey];
     }
 }
Example #5
0
 /**
  * Creates a new user account if all inputs are valid.
  * This method responds to the OnClick event of the "create" button.
  * @param mixed event sender
  * @param mixed event parameter
  */
 public function createButtonClicked($sender, $param)
 {
     if ($this->IsValid) {
         // populates a UserRecord object with user inputs
         $userRecord = new UserRecord();
         $userRecord->username = $this->Username->Text;
         $userRecord->password = $this->Password->Text;
         $userRecord->email = $this->Email->Text;
         $userRecord->role = (int) $this->Role->SelectedValue;
         $userRecord->first_name = $this->FirstName->Text;
         $userRecord->last_name = $this->LastName->Text;
         // saves to the database via Active Record mechanism
         $userRecord->save();
         // redirects the browser to the homepage
         $this->Response->redirect($this->Service->DefaultPageUrl);
     }
 }
Example #6
0
 /**
  * Creates a new user account if all inputs are valid.
  * This method responds to the OnClick event of the "create" button.
  * @param mixed event sender
  * @param mixed event parameter
  */
 public function createButtonClicked($sender, $param)
 {
     if ($this->IsValid) {
         // populates a UserRecord object with user inputs
         $userRecord = new UserRecord();
         $userRecord->user_username = $this->Username->Text;
         $userRecord->user_password = $this->Password->Text;
         $userRecord->user_mail = $this->Email->Text;
         $userRecord->idtm_user_role = (int) $this->Role->SelectedValue;
         $userRecord->user_vorname = $this->FirstName->Text;
         $userRecord->user_name = $this->LastName->Text;
         // saves to the database via Active Record mechanism
         $userRecord->save();
         $parteiRecord = new ParteiRecord();
         $parteiRecord->idtm_user = $userRecord->idtm_user;
         $parteiRecord->partei_name = $this->FirstName->Text . " " . $this->LastName->Text;
         //save the partei
         $parteiRecord->save();
         $adressRecord = new AdresseRecord();
         $adressRecord->adresse_street = $this->adresse_street->Text;
         $adressRecord->adresse_zip = $this->adresse_zip->Text;
         $adressRecord->adresse_town = $this->adresse_town->Text;
         $adressRecord->idtm_country = 1;
         //lets add the coordinates
         $myGTranslator = new GoogleAdressTranslator();
         $mapparams = $myGTranslator->getLatAndLong(implode(",", array($this->adresse_street->Text, $this->adresse_town->Text)));
         $myLatandLong = explode(",", $mapparams);
         //here we check, if the coordinates have been found
         if ($myLatandLong[1] != 0) {
             $adressRecord->adresse_lat = $myLatandLong[1];
             $adressRecord->adresse_long = $myLatandLong[0];
         } else {
             $adressRecord->adresse_lat = "48.189950";
             $adressRecord->adresse_long = "16.377319";
         }
         $adressRecord->save();
         $parteiadresseRecord = new ParteiAdresseRecord();
         $parteiadresseRecord->idta_partei = $parteiRecord->idta_partei;
         $parteiadresseRecord->idta_adresse = $adressRecord->idta_adresse;
         //save adress to partei
         $parteiadresseRecord->save();
         // redirects the browser to the homepage
         $this->Response->redirect($this->Service->DefaultPageUrl);
     }
 }
Example #7
0
 /**
  * Deletes a specified user record.
  * This method responds to the datagrid's OnDeleteCommand event.
  * @param TDataGrid the event sender
  * @param TDataGridCommandEventParameter the event parameter
  */
 public function deleteButtonClicked($sender, $param)
 {
     // obtains the datagrid item that contains the clicked delete button
     $item = $param->Item;
     // obtains the primary key corresponding to the datagrid item
     $username = $this->UserGrid->DataKeys[$item->ItemIndex];
     // deletes the user record with the specified username primary key
     UserRecord::finder()->deleteByPk($username);
 }
 public function buildStammdatenGroupPullDown()
 {
     $this->RCedidta_struktur_type->DataSource = PFH::build_SQLPullDown(StrukturTypeRecord::finder(), "ta_struktur_type", array("idta_struktur_type", "struktur_type_name"));
     $this->RCedidta_struktur_type->dataBind();
     $Usersql = "SELECT idtm_user, user_name FROM tm_user";
     $Userdata = PFH::convertdbObjectArray(UserRecord::finder()->findAllBySql($Usersql), array("idtm_user", "user_name"));
     $this->idtm_user->DataSource = $Userdata;
     $this->idtm_user->dataBind();
 }
 public function getThreadById($id)
 {
     $record = craft()->forum_thread->getThreadById($id);
     $record->replies = array_map(function ($reply) {
         $reply->user = UserRecord::model()->findById($reply->userId);
         return $reply;
     }, $record->replies);
     return $record;
 }
Example #10
0
 public function destroy()
 {
     $user_record = UserRecord::find($this->params()->id);
     if ($this->current_user->is_mod_or_higher() || $this->current_user->id == $user_record->reported_by) {
         $user_record->destroy();
         $this->respond_to_success("Record updated", ["#index", 'user_id' => $this->params()->id]);
     } else {
         $this->access_denied();
     }
 }
Example #11
0
 public function editRow($sender, $param)
 {
     if ($this->IsValid) {
         $baseMethod = new BaseFunction();
         $qty = UserRecord::finder()->count();
         if (UserRecord::finder()->findByName($this->Login->getSafeText())) {
             $this->InCorrect->Visible = true;
         } else {
             $rows = new UserRecord();
             $rows->Username = $baseMethod->cryptString($this->Login->getSafeText());
             $rows->Email = $baseMethod->cryptString($this->Login->getSafeText());
             $rows->Password = $baseMethod->cryptString($this->Password->getSafeText());
             $rows->Role = 0;
             $rows->PagesID = $this->getRequest()->itemAt("id");
             $rows->Name = $this->Login->getSafeText();
             $rows->ID = $qty + 1;
             $rows->save();
             $this->Response->redirect($this->Service->constructUrl("User.Index", array("id" => $this->getRequest()->itemAt("id"))));
         }
     }
 }
Example #12
0
 public function getUserId($username = '')
 {
     if ($username == '') {
         $userRecord = UserRecord::finder()->find('user_username = ?', $this->Name);
     } else {
         $userRecord = UserRecord::finder()->find('user_username = ?', $username);
     }
     if (is_Object($userRecord)) {
         return $userRecord->idtm_user;
     } else {
         return 0;
     }
 }
 /**
  * Handle the onBeforeSaveUser event.
  *
  * @param Event $event
  */
 public function onBeforeSaveUser(Event $event)
 {
     // Get user id to save
     $id = $event->params['user']->id;
     if (!$event->params['isNewUser']) {
         // Get old user from db
         $user = UserModel::populateModel(UserRecord::model()->findById($id));
         // Get fields
         $this->before = $this->fields($user);
     } else {
         // Get fields
         $this->before = $this->fields($event->params['user'], true);
     }
 }
Example #14
0
 /**
  * Returns the user data to be editted.
  * @return UserRecord the user data to be editted.
  * @throws THttpException if the user data is not found.
  */
 protected function getUserRecord()
 {
     // the user to be editted is the currently logged-in user
     $username = $this->User->Name;
     // if the 'username' GET var is not empty and the current user
     // is an administrator, we use the GET var value instead.
     if ($this->User->IsAdmin && $this->Request['username'] !== null) {
         $username = $this->Request['username'];
     }
     // use Active Record to look for the specified username
     $userRecord = UserRecord::finder()->findByPk($username);
     if (!$userRecord instanceof UserRecord) {
         throw new THttpException(500, 'Username is invalid.');
     }
     return $userRecord;
 }
Example #15
0
 function saveNewUserAction()
 {
     if (!empty($this->request->login) && !empty($this->request->password) && !empty($this->request->role) && in_array($this->request->role, array("moderator", "administrator"))) {
         $user = new UserRecord();
         $user->login = $this->request->login;
         $user->email = $user->login;
         $user->password = md5($this->request->password);
         $user->role = $this->request->role;
         $user->save();
         $refusal = new RefusalRecord();
         $refusal->moderatorId = $user->userId;
         $refusal->refusedSitesCount = 0;
         $refusal->save();
     }
     $this->redirect($this->moduleLink($this->request->role));
 }
 public function onLoad($param)
 {
     parent::onLoad($param);
     date_default_timezone_set('Europe/Berlin');
     //$this->SBedidta_struktur_type->Text = $this->page->idta_struktur_type->Text;
     if (!$this->page->isPostBack && !$this->page->isCallback) {
         //$this->buildStrukturBerichtPullDown();
         $this->bindListStrukturBerichtValue();
         $this->buildStrukturBerichtZeilenPullDown();
         $this->buildStrukturBerichtSpaltenPullDown();
         $Usersql = "SELECT idtm_user, user_name FROM tm_user";
         $Userdata = PFH::convertdbObjectArray(UserRecord::finder()->findAllBySql($Usersql), array("idtm_user", "user_name"));
         $this->idtm_user->DataSource = $Userdata;
         $this->idtm_user->dataBind();
     }
 }
 public function onLoad($param)
 {
     parent::onLoad($param);
     if (!$this->page->IsPostBack && !$this->page->IsCallback) {
         $PeriodPullDown = new PFPeriodPullDown();
         $PeriodPullDown->setStructureTable("ta_perioden");
         $PeriodPullDown->setRecordClass(PeriodenRecord::finder());
         $PeriodPullDown->setPKField("idta_perioden");
         $PeriodPullDown->setField("per_extern");
         $PeriodPullDown->letsrun();
         $this->RCedidta_perioden->DataSource = $PeriodPullDown->myTree;
         $this->RCedidta_perioden->dataBind();
         $Usersql = "SELECT idtm_user, user_name FROM tm_user";
         $Userdata = PFH::convertdbObjectArray(UserRecord::finder()->findAllBySql($Usersql), array("idtm_user", "user_name"));
         $this->var_idtm_user->DataSource = $Userdata;
         $this->var_idtm_user->dataBind();
         $this->bindListVariantenValue();
     }
 }
 public function changePassword2($sender, $param)
 {
     $finder = UserRecord::finder();
     $finder->DbConnection->Active = true;
     $transaction = $finder->DbConnection->beginTransaction();
     try {
         $baseMethod = new BaseFunction();
         $hash = $this->getRequest()->itemAt("amp;hash");
         if ($this->getRequest()->contains("amp;hash") == false) {
             $hash = $this->getRequest()->itemAt("hash");
         }
         $rows = $finder->findByUsername($hash);
         $rows->Password = TPropertyValue::ensureString($baseMethod->cryptString($this->ConfirmPassword->getSafeText()));
         $rows->save();
         $transaction->commit();
     } catch (Exception $e) {
         print_R($e->getMessage());
         $transaction->rollBack();
     }
     $this->Response->redirect($this->Service->constructUrl("Login"));
 }
 public function __construct($isActive = NULL, $isEmailNotificationAllowed = NULL, $externalId = NULL, $ordersUiLocalTimeZoneId = NULL, $customFieldValues = NULL, $id = NULL, $name = NULL, $email = NULL, $roleId = NULL, $roleName = NULL, $preferredLocale = NULL, $UserRecordType = NULL)
 {
     parent::__construct();
     $this->isActive = $isActive;
     $this->isEmailNotificationAllowed = $isEmailNotificationAllowed;
     $this->externalId = $externalId;
     $this->ordersUiLocalTimeZoneId = $ordersUiLocalTimeZoneId;
     $this->customFieldValues = $customFieldValues;
     $this->id = $id;
     $this->name = $name;
     $this->email = $email;
     $this->roleId = $roleId;
     $this->roleName = $roleName;
     $this->preferredLocale = $preferredLocale;
     $this->UserRecordType = $UserRecordType;
 }
Example #20
0
 public function __construct($isActive = NULL, $isEmailNotificationAllowed = NULL, $id = NULL, $name = NULL, $email = NULL, $roleId = NULL, $roleName = NULL, $preferredLocale = NULL, $teamIds = NULL, $UserRecordType = NULL)
 {
     if (get_parent_class('User')) {
         parent::__construct();
     }
     $this->isActive = $isActive;
     $this->isEmailNotificationAllowed = $isEmailNotificationAllowed;
     $this->id = $id;
     $this->name = $name;
     $this->email = $email;
     $this->roleId = $roleId;
     $this->roleName = $roleName;
     $this->preferredLocale = $preferredLocale;
     $this->teamIds = $teamIds;
     $this->UserRecordType = $UserRecordType;
 }
 /**
  * Gets a user record by its ID.
  *
  * @param int $userId
  *
  * @throws Exception
  * @return UserRecord
  */
 private function _getUserRecordById($userId)
 {
     $userRecord = UserRecord::model()->findById($userId);
     if (!$userRecord) {
         throw new Exception(Craft::t('No user exists with the ID “{id}”.', array('id' => $userId)));
     }
     return $userRecord;
 }
Example #22
0
<?php

/**
 * Created by PhpStorm.
 * User: andre_000
 * Date: 05.09.2015
 * Time: 21:01
 */
if (isset($_POST["login"])) {
    include "dedugan.php";
    $pd = connectDB();
    $user = new UserRecord();
    if ($user->isLoginFree($_POST["login"], $pd) != 0) {
        echo "Логин занят";
    } else {
        echo "Логин свободен";
    }
} else {
    echo "error!!!";
}
Example #23
0
 public function view_Organisation($idtm_organisation)
 {
     $myitem = OrganisationRecord::finder()->findByPK($idtm_organisation);
     $tempus = 'RCed' . $this->RCprimarykey;
     $monus = $this->RCprimarykey;
     $this->{$tempus}->Text = $myitem->{$monus};
     $this->bindListAdress();
     $this->bindListKom();
     $this->viewMainAdress($idtm_organisation);
     //HIDDEN
     foreach ($this->RChiddenfields as $recordfield) {
         $edrecordfield = 'RCed' . $recordfield;
         $this->{$edrecordfield}->setText($myitem->{$recordfield});
     }
     //DATUM
     foreach ($this->RCdatfields as $recordfield) {
         $edrecordfield = 'RCed' . $recordfield;
         $this->{$edrecordfield}->setDate($myitem->{$recordfield});
     }
     //BOOL
     foreach ($this->RCboolfields as $recordfield) {
         $edrecordfield = 'RCed' . $recordfield;
         $this->{$edrecordfield}->setChecked($myitem->{$recordfield});
     }
     //TIME
     foreach ($this->RCtimefields as $recordfield) {
         $edrecordfield = 'RCed' . $recordfield;
         $my_time = explode(':', $myitem->{$recordfield});
         $my_time_text = $my_time[0] . ':' . $my_time[1];
         $this->{$edrecordfield}->Text = $my_time_text;
     }
     //NON DATUM
     foreach ($this->RCfields as $recordfield) {
         $edrecordfield = 'RCed' . $recordfield;
         $this->{$edrecordfield}->Text = $myitem->{$recordfield};
     }
     $this->RCedorganisation_edit_status->Text = 1;
     $ActualUser = UserRecord::finder()->findByidtm_user($this->RCedidtm_user->Text);
     if (is_Object($ActualUser)) {
         $this->suggest_idtm_user->Text = $ActualUser->user_username;
     } else {
         $this->suggest_idtm_user->Text = 0;
     }
     $this->loadBankkonto($this->{$tempus}->Text);
     $this->loadObjekt($this->{$tempus}->Text);
     $this->laborg_name->Text = $myitem->org_name;
     $ParentOrga = OrganisationRecord::finder()->findByidtm_organisation($myitem->parent_idtm_organisation);
     if (is_Object($ParentOrga)) {
         $this->labparentorg_name->Text = $ParentOrga->org_name . ', ' . $ParentOrga->org_vorname;
     }
     $this->labparentorg_name->CommandParameter = $myitem->parent_idtm_organisation;
     //Rechnungen
     //$this->Teddeb_id->Text = $myitem->$monus;
     //$this->Teddeb_tabelle->Text = 'tm_zeiterfassung';
     //$this->RechnungContainer->initParameters();
     $this->RechnungContainer->bindRechnungListe();
     //TASKPART
     $this->Tedsend_id->Text = $myitem->{$monus};
     $this->Tedauf_id->Text = $myitem->{$monus};
     $this->AufgabenContainerOrganisation->initParameters();
     $this->AufgabenContainerOrganisation->initYearPullDown();
     $this->AufgabenContainerOrganisation->bindListTAValue();
     $this->setPDFSteckbrief($myitem->{$monus});
     $this->bindListChildOrgListe();
 }
 public function __construct($isActive = null, $isEmailNotificationAllowed = null, $externalId = null, $isServiceAccount = null, $ordersUiLocalTimeZoneId = null, $customFieldValues = null, $id = null, $name = null, $email = null, $roleId = null, $roleName = null, $preferredLocale = null)
 {
     parent::__construct();
     $this->isActive = $isActive;
     $this->isEmailNotificationAllowed = $isEmailNotificationAllowed;
     $this->externalId = $externalId;
     $this->isServiceAccount = $isServiceAccount;
     $this->ordersUiLocalTimeZoneId = $ordersUiLocalTimeZoneId;
     $this->customFieldValues = $customFieldValues;
     $this->id = $id;
     $this->name = $name;
     $this->email = $email;
     $this->roleId = $roleId;
     $this->roleName = $roleName;
     $this->preferredLocale = $preferredLocale;
 }
Example #25
0
File: User.php Project: rrnntt/php
 /**
  * Checks if the specified (username, password) is valid.
  * This method is required by TDbUser.
  * @param string username
  * @param string password
  * @return boolean whether the username and password are valid.
  */
 public function validateUser($username, $password)
 {
     // use UserRecord Active Record to look for the (username, password) pair.
     return UserRecord::finder()->findBy_username_AND_password($username, $password) !== null;
 }
 /**
  * Delete all the photos for current user.
  */
 public function actionDeleteUserPhoto()
 {
     $this->requireAjaxRequest();
     craft()->userSession->requireLogin();
     $userId = craft()->request->getRequiredPost('userId');
     if ($userId != craft()->userSession->getUser()->id) {
         craft()->userSession->requirePermission('editUsers');
     }
     $user = craft()->users->getUserById($userId);
     craft()->users->deleteUserPhoto($user);
     $record = UserRecord::model()->findById($user->id);
     $record->photo = null;
     $record->save();
     // Since Model still believes it has an image, we make sure that it does not so anymore when it reaches the template.
     $user->photo = null;
     $html = craft()->templates->render('users/_edit/_userphoto', array('account' => $user));
     $this->returnJson(array('html' => $html));
 }
Example #27
0
 public function validateUser($username, $password)
 {
     $baseMethod = new BaseFunction();
     return UserRecord::finder()->findBy_Username_AND_Password($baseMethod->cryptString($username), $baseMethod->cryptString($password));
 }
Example #28
0
      <td><strong><?php 
echo $this->t('user_record');
?>
</strong></td>
      <td>
        <?php 
if (!UserRecord::where("user_id = ?", $this->user->id)->exists()) {
    ?>
          <?php 
    echo $this->t('user_record_none');
    ?>
        <?php 
} else {
    ?>
          <?php 
    echo UserRecord::where("user_id = ? AND is_positive = true", $this->user->id)->count() - UserRecord::where("user_id = ? AND is_positive = false", $this->user->id)->count();
    ?>
        <?php 
}
?>
        (<?php 
echo $this->linkTo($this->t('user_record_add'), array('user_record#index', 'user_id' => $this->user->id));
?>
)
      </td>
    </tr>
    <?php 
if (current_user()->is_mod_or_higher()) {
    ?>
      <tr>
        <td><strong><?php 
Example #29
0
 public function invite($name, $level)
 {
     if ($this->invite_count <= 0) {
         throw new User_NoInvites();
     }
     if ((int) $level >= CONFIG()->user_levels["Contributor"]) {
         $level = CONFIG()->user_levels["Contributor"];
     }
     $invitee = User::where(['name' => $name])->first();
     if (!$invitee) {
         throw new Rails\ActiveRecord\Exception\RecordNotFoundException();
     }
     if (UserRecord::where("user_id = ? AND is_positive = false AND reported_by IN (SELECT id FROM users WHERE level >= ?)", $invitee->id, CONFIG()->user_levels["Mod"])->exists() && !$this->is_admin()) {
         throw new User_HasNegativeRecord();
     }
     // transaction do
     if ($level == CONFIG()->user_levels["Contributor"]) {
         Post::where("user_id = ? AND status = 'pending'", $this->id)->take()->each(function ($post) {
             $post->approve($id);
         });
     }
     $invitee->level = $level;
     $invitee->invited_by = $this->id;
     $invitee->save();
     # iTODO: add support for decrement!
     // decrement! :invite_count
     self::connection()->executeSql("UPDATE users SET invite_count = invite_count - 1 WHERE id = " . $this->id);
     $this->invite_count--;
     // end
 }
Example #30
0
 /**
  * Register webmaster from ajax query
  */
 function registerAction()
 {
     $this->viewClass = "JsonView";
     $errorMessage = $this->validateRegistration();
     if (!$errorMessage) {
         $user = new UserRecord();
         $user->email = $this->request->email;
         $user->password = md5($this->request->password);
         $user->role = 'webmaster';
         if (Config::get("emailConfirmationEnabled")) {
             $user->active = 0;
         }
         $user->save();
         if (Config::get("emailConfirmationEnabled")) {
             $this->set("message", _t("The registration was successful! You must confirm your email. Check your inbox."));
             $verification = $this->verification->addVerification($user->userId, "userEmail");
             $confirmLink = Config::get("siteRootUrl") . $this->moduleLink("confirmUserEmail/" . $verification->code, false);
             Mailer::getInstance()->sendEmailConfirmation("userEmail", $user->email, $confirmLink);
         } else {
             $this->set("message", _t("The registration was successful! You can login now."));
         }
         $this->set("status", "ok");
     } else {
         //something is wrong with webmasterData
         $this->set("status", "error");
         $this->set("message", _t($errorMessage));
     }
 }