Esempio n. 1
0
 public function sellCar(Persons $buyer)
 {
     $currentCar = $this->nextCar();
     if ($buyer->buyCar($currentCar)) {
         $currentCar->setOwner($buyer);
         $this->removeCar($currentCar);
     }
 }
Esempio n. 2
0
 /**
  * @covers Geissler\Converter\Model\Container::getIterator
  */
 public function testGetIterator()
 {
     $this->assertInstanceOf('\\ArrayIterator', $this->object->getIterator());
     $this->assertInstanceOf('\\Geissler\\Converter\\Model\\Persons', $this->object->setPerson(new Person()));
     $this->assertInstanceOf('\\Geissler\\Converter\\Model\\Persons', $this->object->setPerson(new Person()));
     foreach ($this->object as $person) {
         $this->assertInstanceOf('\\Geissler\\Converter\\Model\\Person', $person);
     }
 }
 /**
  * @param Persons $body
  *
  * Adding participants for time travel
  */
 public function addBody(Persons $body)
 {
     switch ($body->getCapacity()) {
         case 0.5:
             $this->children[] = $body;
             break;
         case 1:
             $this->adults[] = $body;
             break;
         default:
             $this->adults[] = $body;
     }
 }
Esempio n. 4
0
 public static function getInstance()
 {
     if (!self::$persons_instance) {
         self::$persons_instance = new Persons();
     }
     return self::$persons_instance;
 }
Esempio n. 5
0
 /**
  * Check email rule
  */
 public function checkEmail() {
     if ($this->email != '') {
         $pattern = '/^([0-9a-zA-Z]([\-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][\-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/';
         if(!preg_match($pattern, $this->email)) {
             $this->addError('email','Email is not valid');
         } else {
             $person = Persons::model()->find('Email=:email',
                 array(':email'=>$this->email));
             if (!$person) {
                 $this->addError('email','Email does not exists');
             }
         }
     }
 }
Esempio n. 6
0
 public function LoadBookPersons($ids)
 {
     $this->getByIdsLoaded($ids);
     $out = array();
     $tofetch = array();
     $aids = array();
     if (is_array($ids)) {
         foreach ($ids as $id) {
             if (!isset($this->items[$id])) {
                 continue;
             }
             if (!$this->items[$id]->personsLoaded) {
                 $tofetch[] = (int) $id;
             }
         }
         $bookPersons = array();
         if (count($tofetch)) {
             $query = 'SELECT * FROM `book_persons` WHERE `id_book` IN (' . implode(',', $tofetch) . ')';
             $bookPersons = Database::sql2array($query);
         }
         $bookPersonsPrepared = array();
         foreach ($bookPersons as $book) {
             $bookPersonsPrepared[$book['id_book']][] = $book;
             $aids[$book['id_person']] = $book['id_person'];
         }
         Persons::getInstance()->getByIdsLoaded($aids);
         foreach ($ids as $id) {
             if (isset($this->items[$id])) {
                 if (isset($bookPersonsPrepared[$id])) {
                     $this->items[$id]->loadPersons(isset($bookPersonsPrepared[$id]) ? $bookPersonsPrepared[$id] : array());
                 } else {
                     // no any persons
                     $this->items[$id]->personsLoaded = true;
                     //$this->items[$id]->persons = array();
                 }
             }
         }
         foreach ($ids as $id) {
             if (isset($this->items[$id])) {
                 $out[$id] = $this->items[$id];
             }
         }
     }
     return $out;
 }
Esempio n. 7
0
 public function checkWcaId()
 {
     $user = Yii::app()->controller->user;
     if ($user->wcaid === '' && $this->wcaid !== '') {
         $person = Persons::model()->findByAttributes(array('id' => $this->wcaid, 'subid' => 1));
         if ($person !== null) {
             $name = $user->name;
             if ($user->name_zh !== '') {
                 $name .= ' (' . $user->name_zh . ')';
             }
             if ($name !== $person->name && $user->name !== $person->name) {
                 $this->addError('wcaid', Yii::t('common', 'Wrong WCA ID'));
             }
         } else {
             $this->addError('wcaid', Yii::t('common', 'Wrong WCA ID'));
         }
     }
 }
 public function updateAction($id, $name, $age, $weight, $height)
 {
     // Retrieve the person we're looking for
     $person = Persons::findById($id);
     // Update the person's information
     $person->set('name', $name);
     $person->set('age', $age);
     $person->set('weight', $weight);
     $person->set('height', $height);
     // Save the person
     $person->save();
     // Store the new information for view rendering
     $this->view->person = $person;
     // Tell the view we're editing
     $this->view->action = 'editing';
     // Render the edit view
     $this->view->render('views/edit');
 }
Esempio n. 9
0
 public static function notifyAuthorNewBook($id_author, $id_book)
 {
     global $current_user;
     $query = 'SELECT `id_user` FROM `author_subscribers` WHERE `id_author`=' . (int) $id_author;
     $user_ids = array_keys(Database::sql2array($query, 'id_user'));
     if (isset($user_ids[$current_user->id])) {
         unset($user_ids[$current_user->id]);
     }
     if (count($user_ids)) {
         $person = Persons::getInstance()->getByIdLoaded($id_author);
         $book = Books::getInstance()->getByIdLoaded($id_book);
         /* @var $person Person */
         $subject = 'Добавлена книга автора ' . $person->getName();
         /* @var $book Book */
         $message = 'Книга <a href="/b/' . $book->id . '">' . $book->getTitle(1) . '</a> добавлена';
         self::send($user_ids, $subject, $message, UserNotify::UN_G_NEW_AUTHORS);
     }
 }
Esempio n. 10
0
 function _show()
 {
     $out = array();
     $this->load();
     if ($redirect_to = $this->getDuplicateId()) {
         $person2 = Persons::getInstance()->getByIdLoaded($redirect_to);
         if ($person2->loaded) {
             @ob_end_clean();
             header('Location: ' . $this->getUrl($redirect = true) . '?redirect=a_' . $this->id);
             exit;
         }
     }
     $out['picture'] = $this->getPicture();
     $langId = $this->data['author_lang'] ? $this->data['author_lang'] : 136;
     foreach (Config::$langs as $code => $id_lang) {
         if ($id_lang == $langId) {
             $langCode = $code;
         }
     }
     $out['lang_code'] = $langCode;
     $out['id'] = $this->id;
     $out['lang_title'] = Config::$langRus[$langCode];
     $out['lang_id'] = $langId;
     $out['first_name'] = $this->data['first_name'];
     $out['last_name'] = $this->data['last_name'];
     $out['middle_name'] = $this->data['middle_name'];
     $out['avg_mark'] = $this->getAvgMark();
     $date_b = timestamp_to_ymd($this->data['date_birth']);
     $date_b = (int) $date_b[0] ? digit2($date_b[2]) . '.' . digit2($date_b[1]) . '.' . $date_b[0] : '';
     $date_d = timestamp_to_ymd($this->data['date_death']);
     $date_d = (int) $date_d[0] ? digit2($date_d[2]) . '.' . digit2($date_d[1]) . '.' . $date_d[0] : '';
     $out['date_birth'] = $date_b;
     $out['date_death'] = $date_d;
     $out['wiki_url'] = $this->data['wiki_url'];
     $out['homepage'] = $this->data['homepage'];
     $out['bio']['html'] = $this->data['bio'];
     $out['bio']['short'] = $this->data['short_bio'];
     $out['lastSave'] = $this->data['authorlastSave'];
     return $out;
 }
Esempio n. 11
0
 function getAuthorContributionComments()
 {
     global $current_user;
     /* @var $current_user CurrentUser */
     $id_author = isset($this->params['author_id']) ? (int) $this->params['author_id'] : false;
     if (!$id_author) {
         throw new Exception('author  not exists');
     }
     $author = Persons::getInstance()->getByIdLoaded($id_author);
     /* @var $author Person */
     if (!$author->exists) {
         throw new Exception('author #' . $author->id . ' not exists');
     }
     $cond = new Conditions();
     $per_page = 0;
     if (isset($this->params['per_page'])) {
         $per_page = (int) $this->params['per_page'];
     }
     $per_page = $per_page > 0 ? $per_page : 20;
     $pagingName = isset($this->params['paging_parameter_name']) ? $this->params['paging_parameter_name'] : 'p';
     $cond->setPaging(1000, $per_page, $pagingName);
     $limit = $cond->getMongoLimit();
     list($comments, $count) = MongoDatabase::getAuthorComments($id_author, $per_page, $limit);
     $uids = array();
     $comments['comments'] = isset($comments['comments']) ? $comments['comments'] : array();
     foreach ($comments['comments'] as &$comment) {
         $comment['commenter_id'] = $comment['user_id'];
         $comment['type'] = 'author';
         $comment['time'] = date('Y/m/d H:i:s', $comment['time']);
         $uids[$comment['user_id']] = $comment['user_id'];
     }
     $cond = new Conditions();
     $cond->setPaging($count, $per_page, $pagingName);
     $this->data['conditions'] = $cond->getConditions();
     $this->data['comments'] = isset($comments['comments']) ? $comments['comments'] : array();
     $this->data['comments']['title'] = 'Обсуждение автора ' . $author->getName() . '';
     $this->data['comments']['count'] = $count;
     $this->data['users'] = $this->getCommentsUsers($uids);
 }
Esempio n. 12
0
 public function checkWcaId()
 {
     $this->wcaid = strtoupper($this->wcaid);
     if ($this->wcaid !== '') {
         switch ($this->step) {
             case 1:
                 $person = Persons::model()->findByAttributes(array('id' => $this->wcaid));
                 if ($person === null) {
                     $this->addError('wcaid', Yii::t('common', 'Wrong WCA ID'));
                     return false;
                 }
                 Yii::app()->session->add(self::REGISTER_WCAID, $this->wcaid);
             case 2:
                 $user = User::model()->findByAttributes(array('wcaid' => $this->wcaid, 'status' => User::STATUS_NORMAL));
                 if ($user !== null) {
                     $this->addError('wcaid', Yii::t('common', 'The WCA ID {wcaid} has been registered.', array('{wcaid}' => $this->wcaid)));
                     return false;
                 }
                 break;
         }
     }
 }
Esempio n. 13
0
 function add_relation()
 {
     global $current_user;
     $this->ca();
     $id1 = isset($_POST['id']) ? (int) $_POST['id'] : false;
     $id2 = isset($_POST['author_id']) ? (int) $_POST['author_id'] : false;
     if ($id1 == $id2) {
         $this->data['error'] = 'Онанизмъ';
         return false;
     }
     $relation_type = isset($_POST['relation_type']) ? (int) $_POST['relation_type'] : false;
     $person1 = Persons::getInstance()->getByIdLoaded($id1);
     $person2 = Persons::getInstance()->getByIdLoaded($id2);
     /* @var $person2 Person */
     if (!$person2 || !$person1) {
         $this->data['error'] = 'Нет такого автора';
         return false;
     }
     if (!$id1 || !$id2 || !$relation_type) {
         throw new Exception('id or item_id or relation_type missed');
     }
     if (PersonRelations::addRelation($id1, $id2, $relation_type)) {
         $this->data['success'] = 1;
         $this->data['item_id'] = $id2;
         $this->data['relation_type'] = PersonRelations::$relation_types[$relation_type];
         /* @var $book2 Book */
         $this->data['title'] = $person2->getName();
         $search = Search::getInstance();
         /* @var $search Search */
         $search->setAuthorToFullUpdate($person2->id);
         $search->setAuthorToFullUpdate($person1->id);
     } else {
         $this->data['success'] = 0;
         $this->data['error'] = 'ошибочка: ' . PersonRelations::getLastError();
     }
 }
Esempio n. 14
0
 function getStatAuthors($aids)
 {
     if (!count($aids)) {
         return array();
     }
     $persons = Persons::getInstance()->getByIdsLoaded($aids);
     $out = array();
     foreach ($persons as $person) {
         $out[] = $person->getListData();
     }
     foreach ($out as &$r) {
         $r['path'] = Config::need('www_path') . '/admin/authors/' . $r['id'];
     }
     return $out;
 }
Esempio n. 15
0
        </div>
        <div class="col-md-4 col-sm-6 col-xs-12 mt-10">
          <span class="info-title"><?php 
echo Yii::t('Results', 'Emulation');
?>
:</span>
          <span class="info-value"><?php 
echo sprintf('%d.%02d.%02d - %d.%02d.%02d', $firstCompetition->year, $firstCompetition->month, $firstCompetition->day, $lastCompetition->year, $lastCompetition->endMonth, $lastCompetition->endDay);
?>
</span>
        </div>
      </div>
    </div>
  </div>
  <h2><?php 
echo Yii::t('Results', 'Current Personal Records') . Persons::getBattleCheckBox($person->name, $person->id, 'span', array('class' => 'small'));
?>
</h2>
  <?php 
$this->widget('GridView', array('dataProvider' => new CArrayDataProvider(array_values($personRanks), array('pagination' => false, 'sort' => false)), 'front' => true, 'template' => '{items}', 'columns' => array(array('name' => Yii::t('common', 'Event'), 'type' => 'raw', 'value' => 'CHtml::link(CHtml::tag("span", array(
          "class"=>"event-icon event-icon event-icon-" . $data->eventId,
          "title"=>Yii::t("event", $data->event->cellName),
        ), Yii::t("event", $data->event->cellName)), "#" . $data->event->id)'), array('name' => Yii::t('statistics', 'NR'), 'type' => 'raw', 'value' => '$data->getRank("countryRank")', 'headerHtmlOptions' => array('class' => 'record')), array('name' => Yii::t('statistics', 'CR'), 'type' => 'raw', 'value' => '$data->getRank("continentRank")', 'headerHtmlOptions' => array('class' => 'record')), array('name' => Yii::t('statistics', 'WR'), 'type' => 'raw', 'value' => '$data->getRank("worldRank")', 'headerHtmlOptions' => array('class' => 'record')), array('name' => Yii::t('common', 'Single'), 'type' => 'raw', 'value' => 'CHtml::link(Results::formatTime($data->best, $data->eventId), array(
          "/results/rankings",
          "event"=>$data->eventId,
          "region"=>$data->person->countryId,
        ))'), array('name' => Yii::t('common', 'Average'), 'type' => 'raw', 'value' => '$data->average("best")'), array('name' => Yii::t('statistics', 'WR'), 'type' => 'raw', 'value' => '$data->average("worldRank")', 'headerHtmlOptions' => array('class' => 'record')), array('name' => Yii::t('statistics', 'CR'), 'type' => 'raw', 'value' => '$data->average("continentRank")', 'headerHtmlOptions' => array('class' => 'record')), array('name' => Yii::t('statistics', 'NR'), 'type' => 'raw', 'value' => '$data->average("countryRank")', 'headerHtmlOptions' => array('class' => 'record')), array('header' => Yii::t('statistics', 'Gold'), 'value' => '$data->medals["gold"] ?: ""'), array('header' => Yii::t('statistics', 'Silver'), 'value' => '$data->medals["silver"] ?: ""'), array('header' => Yii::t('statistics', 'Bronze'), 'value' => '$data->medals["bronze"] ?: ""'), array('header' => Yii::t('statistics', 'Solves/Attempts'), 'value' => '$data->medals["solve"] . "/" . $data->medals["attempt"]'))));
?>
  <h2><?php 
echo Yii::t('statistics', 'Sum of Ranks');
?>
Esempio n. 16
0
        <?php 
}
?>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td colspan="2"><?php 
echo Yii::t('common', 'WCA ID');
?>
</td>
        <?php 
foreach ($persons as $person) {
    ?>
        <td><?php 
    echo Persons::getWCAIconLinkByNameNId($person['person']->name, $person['person']->id);
    ?>
</td>
        <?php 
}
?>
      </tr>
      <tr>
        <td colspan="2"><?php 
echo Yii::t('common', 'Region');
?>
</td>
        <?php 
foreach ($persons as $person) {
    ?>
        <td><?php 
<?php

include $_SERVER["DOCUMENT_ROOT"] . "/College_Portal/app/models/Persons.php";
include $_SERVER["DOCUMENT_ROOT"] . "/College_Portal/app/views/session.php";
include $_SERVER["DOCUMENT_ROOT"] . "/College_Portal/app/models/student.php";
include $_SERVER["DOCUMENT_ROOT"] . "/College_Portal/app/models/Stuff.php";
// require_once '../session.php';
include $_SERVER["DOCUMENT_ROOT"] . "/College_Portal/app/models/course.php";
if (isset($_POST["email"]) && isset($_POST["password"])) {
    $data = Persons::login($_POST["email"], $_POST["password"]);
    if (is_null($data)) {
        echo " email or password incorrect";
    } else {
        $_SESSION['person_id'] = $data['id'];
        $_SESSION['studentOrNot'] = $data['isStudentorNot'];
        if ($data['isStudentorNot'] == 1) {
            $courses = Student::get_Courses($_SESSION['person_id']);
            $course = $courses[0];
            $course_code = Course::get_name_code($course);
            header("Location:../views/student/?course=" . $course_code);
        } else {
            $courses = Stuff::get_Courses($_SESSION['person_id']);
            $course = $courses[0];
            $course_code = Course::get_name_code($course);
            header("Location:../views/stuff/?course=" . $course_code);
        }
    }
} else {
    echo "email or password not set";
}
Esempio n. 18
0
    function write() {
        global $current_user;
        $id = isset(Request::$post['id']) ? (int) Request::$post['id'] : false;

        if (!$id)
            $this->newAuthor();


        $persons = Persons::getByIdsLoaded(array($id));
        $person = is_array($persons) ? $persons[$id] : false;
        if (!$person)
            return;
        $savedData = $person->data;
        /* @var $book Book */

        $fields = array(
            'lang_code' => 'author_lang', //lang_code
            'bio' => 'bio',
            'first_name' => 'first_name',
            'middle_name' => 'middle_name',
            'last_name' => 'last_name',
            //'id_user' => 'id_user',
            'homepage' => 'homepage',
            'wiki_url' => 'wiki_url',
            'date_birth' => 'date_birth',
            'date_death' => 'date_death'
        );

        Request::$post['lang_code'] = Config::$langs[Request::$post['lang_code']];
        $to_update = array();
        if (isset($_FILES['picture']) && $_FILES['picture']['tmp_name']) {
            $folder = Config::need('static_path') . '/upload/authors/' . (ceil($person->id / 5000));
            @mkdir($folder);
            chmod($folder, 755);
            $filename = $folder . '/' . $person->id . '.jpg';
            $upload = new UploadAvatar($_FILES['picture']['tmp_name'], 100, 100, "simple", $filename);
            if ($upload->out)
                $to_update['has_cover'] = 1;
            else {
                throw new Exception('cant copy file to ' . $filename, 100);
            }
        }


        foreach ($fields as $field => $personfield) {
            if (!isset(Request::$post[$field])) {
                throw new Exception('field missed #' . $field);
            }
            if ($person->data[$personfield] != Request::$post[$field]) {
                $to_update[$personfield] = Request::$post[$field];
            }
        }

        $q = array();
        if (count($to_update))
            $to_update['authorlastSave'] = time();

        foreach ($to_update as $field => &$value) {
            if ($field == 'date_birth' || $field == 'date_death') {
                $value = getDateFromString($value);
            }

            if ($field == 'bio') {
                list($full, $short) = $person->processBio($value);
                $q[] = '`bio`=' . Database::escape($full) . '';
                $q[] = '`short_bio`=' . Database::escape($short) . '';
                $value = $person->data['bio'] = $full;
                $person->data['short_bio'] = $short;
            } else {
                $q[] = '`' . $field . '`=' . Database::escape($value) . '';
                $person->data[$field] = $value;
            }
        }

        if (count($q)) {
            $query = 'UPDATE `persons` SET ' . implode(',', $q) . ' WHERE `id`=' . $person->id;
            Database::query($query);
            unset($to_update['authorlastSave']);
            PersonLog::addLog($to_update, $savedData);
            PersonLog::saveLog($person->id, BiberLog::TargetType_person, $current_user->id, BiberLog::BiberLogType_personEdit);
        }
    }
Esempio n. 19
0
 function getContributionAuthors($aids)
 {
     if (!count($aids)) {
         return array();
     }
     $persons = Persons::getInstance()->getByIdsLoaded($aids);
     $out = array();
     foreach ($persons as $person) {
         $out[] = $person->getListData();
     }
     return $out;
 }
Esempio n. 20
0
 public function getWcaLink($name = null)
 {
     if ($name === null) {
         $name = $this->getCompetitionName();
     }
     if ($this->wcaid === '' || $name === '') {
         return $name;
     }
     return Persons::getLinkByNameNId($name, $this->wcaid);
 }
Esempio n. 21
0
 function add_author()
 {
     global $current_user;
     $this->ca();
     $id_person = (int) $_POST['id_author'];
     $id_book = (int) $_POST['id'];
     $id_role = (int) $_POST['id_role'];
     if ($id_role && $id_person && $id_book) {
         $persons = Persons::getInstance()->getByIdsLoaded(array($id_person));
         if (!isset($persons[$id_person]) || !$persons[$id_person]->id) {
             $this->data['item_id'] = $id_person;
             $this->data['success'] = 0;
             $this->data['error'] = 'Нет такого автора';
             return;
         }
         $query = 'INSERT INTO `book_persons` SET `id_book`=' . $id_book . ' , `id_person`=' . $id_person . ', `person_role`=' . $id_role;
         $r = Database::query($query, false);
         if ($r) {
             $this->data['success'] = 1;
             $this->data['item_id'] = $id_person;
             $this->data['name'] = $persons[$id_person]->getName();
             $this->data['role'] = Config::$person_roles[$id_role];
             BookLog::addLog(array('id_person' => $id_person, 'person_role' => $id_role), array('id_person' => 0, 'person_role' => 0), $id_book);
             $log_id = BookLog::saveLog($id_book, BookLog::TargetType_book, $current_user->id, BiberLog::BiberLogType_bookEditPerson);
             BookLog::saveLogLink($log_id, $id_person, BookLog::TargetType_person, $current_user->id, BiberLog::BiberLogType_bookEditPerson, $copy = 1);
             $search = Search::getInstance();
             /* @var $search Search */
             $search->updateBook(new Book($id_book));
             Notify::notifyAuthorNewBook($id_person, $id_book);
         } else {
             $this->data['error'] = 'Автор уже есть в списке авторов';
         }
         return;
     }
     $this->data['item_id'] = $id_person;
     $this->data['success'] = 0;
 }
Esempio n. 22
0
 function write()
 {
     global $current_user;
     $current_user->can_throw('books_edit');
     $id = isset(Request::$post['id']) ? (int) Request::$post['id'] : false;
     if (!$id) {
         $this->newAuthor();
         return;
     }
     $person = Persons::getInstance()->getByIdLoaded($id);
     if (!$person) {
         return;
     }
     $savedData = $person->data;
     /* @var $book Book */
     $fields = array('lang_code' => 'author_lang', 'bio' => 'bio', 'first_name' => 'first_name', 'middle_name' => 'middle_name', 'last_name' => 'last_name', 'homepage' => 'homepage', 'wiki_url' => 'wiki_url', 'date_birth' => 'date_birth', 'date_death' => 'date_death');
     if (!Request::$post['first_name'] || !Request::$post['last_name']) {
         throw new Exception('no author\'s name');
     }
     if (!Request::$post['lang_code']) {
         throw new Exception('no author\'s language');
     }
     Request::$post['lang_code'] = Config::$langs[Request::$post['lang_code']];
     $to_update = array();
     if (isset($_FILES['picture']) && $_FILES['picture']['tmp_name']) {
         $folder = Config::need('static_path') . '/upload/authors/' . ceil($person->id / 5000);
         @mkdir($folder);
         // inserting new cover
         $query = 'INSERT INTO `person_covers` SET `id_person`=' . $person->id;
         Database::query($query);
         $cover_id = Database::lastInsertId();
         // generating file names
         $filename_normal = $folder . '/default_' . $person->id . '_' . $cover_id . '.jpg';
         $filename_small = $folder . '/small_' . $person->id . '_' . $cover_id . '.jpg';
         $filename_big = $folder . '/big_' . $person->id . '_' . $cover_id . '.jpg';
         $filename_orig = $folder . '/orig_' . $person->id . '_' . $cover_id . '.jpg';
         $to_update['has_cover'] = $cover_id;
         $thumb = new Thumb();
         $thumb->createThumbnails($_FILES['picture']['tmp_name'], array($filename_small, $filename_normal, $filename_big, $filename_orig), self::$cover_sizes);
         if ($savedData['has_cover']) {
             $current_user->gainActionPoints('authors_add_cover', $person->id, BiberLog::TargetType_person);
         } else {
             $current_user->gainActionPoints('authors_edit_cover', $person->id, BiberLog::TargetType_person);
         }
     }
     foreach ($fields as $field => $personfield) {
         if (!isset(Request::$post[$field])) {
             throw new Exception('field missed #' . $field);
         }
         if ($person->data[$personfield] != Request::$post[$field]) {
             $to_update[$personfield] = Request::$post[$field];
         }
     }
     $q = array();
     if (count($to_update)) {
         $to_update['authorlastSave'] = time();
     }
     foreach ($to_update as $field => &$value) {
         if ($field == 'date_birth' || $field == 'date_death') {
             $value = getDateFromString($value);
         }
         if ($field == 'bio') {
             list($full, $short) = $person->processBio($value);
             $q[] = '`bio`=' . Database::escape($full) . '';
             $q[] = '`short_bio`=' . Database::escape($short) . '';
             $value = $person->data['bio'] = $full;
             $person->data['short_bio'] = $short;
         } else {
             $q[] = '`' . $field . '`=' . Database::escape($value) . '';
             $person->data[$field] = $value;
         }
     }
     if (count($q)) {
         $query = 'UPDATE `persons` SET ' . implode(',', $q) . ' WHERE `id`=' . $person->id;
         Database::query($query);
         unset($to_update['authorlastSave']);
         PersonLog::addLog($to_update, $savedData, $person->id);
         PersonLog::saveLog($person->id, BiberLog::TargetType_person, $current_user->id, BiberLog::BiberLogType_personEdit);
         Persons::getInstance()->dropCache($person->id);
         $current_user->gainActionPoints(BiberLog::$actionTypes[BiberLog::BiberLogType_personEdit], $person->id, BiberLog::TargetType_person);
         $search = Search::getInstance();
         /* @var $search Search */
         $search->setAuthorToFullUpdate($person->id);
     }
     ob_end_clean();
     header('Location:' . Config::need('www_path') . '/a/' . $person->id);
     exit;
 }
Esempio n. 23
0
 function getLogPersons($ids)
 {
     $persons = Persons::getInstance()->getByIdsLoaded($ids);
     $out = array();
     if (is_array($persons)) {
         foreach ($persons as $person) {
             $out[] = $person->getListData();
         }
     }
     return $out;
 }
Esempio n. 24
0
 function getAuthorRelations()
 {
     if (!$this->params['author_id']) {
         return;
     }
     $person = Persons::getInstance()->getByIdLoaded($this->params['author_id']);
     foreach (PersonRelations::$relation_types as $id => $title) {
         $this->data['author']['relation_types'][] = array('id' => $id, 'name' => $title);
     }
     /* @var $person Person */
     if (!$person->loaded) {
         return false;
     }
     $aids = array();
     if ($basket_id = $person->getBasketId()) {
         $query = 'SELECT * FROM `person_basket` WHERE `id_basket`=' . $basket_id;
         $relations = Database::sql2array($query);
         foreach ($relations as $relation) {
             $aids[$relation['id_person']] = $relation['id_person'];
         }
         Persons::getInstance()->getByIdsLoaded($aids);
         foreach ($relations as &$relation) {
             if ($relation['id_person'] == $person->id) {
                 continue;
             }
             $relperson = Persons::getInstance()->getByIdLoaded($relation['id_person']);
             $aids[$relation['id_person']] = $relation['id_person'];
             if ($person->getLangId() != $relperson->getLangId()) {
                 $relation['type'] = PersonRelations::RELATION_TYPE_TRANSLATE;
             } else {
                 $relation['type'] = PersonRelations::RELATION_TYPE_EDITION;
             }
             $relation['relation_type_name'] = PersonRelations::$relation_types[$relation['type']];
             $relation['id1'] = $person->id;
             $relation['id2'] = $relation['id_person'];
             $this->data['author']['relations'][] = $relation;
         }
     }
     $query = 'SELECT `id`,`is_p_duplicate` FROM `persons` WHERE `is_p_duplicate`=' . $person->id . ' OR `id`=' . $person->id;
     $rows = Database::sql2array($query);
     if (count($rows)) {
         foreach ($rows as $row) {
             if ($row['is_p_duplicate']) {
                 $relation = array('desc' => $row['id'] . ' is duplicate for ' . $row['is_p_duplicate'], 'id2' => (int) $row['id'], 'id1' => (int) $row['is_p_duplicate'], 'id_person' => (int) $row['id'], 'type' => PersonRelations::RELATION_TYPE_DUPLICATE, 'relation_type_name' => PersonRelations::$relation_types[PersonRelations::RELATION_TYPE_DUPLICATE]);
                 $this->data['author']['relations'][] = $relation;
                 $aids[$row['id']] = $row['id'];
                 $aids[$row['is_p_duplicate']] = $row['is_p_duplicate'];
             }
         }
     }
     $data = $this->_idsToData(array_keys($aids));
     $this->data['author']['relations']['authors'] = $data['authors'];
 }
Esempio n. 25
0
 <div class = "newmessages">
<h1>New messages</h1>
 
 	
     <p > <?php 
// $course_code = $_GET['course'];
//$course_id = Course::get_id($course_code);
// $course_id = $_GET['Stuff'];
$courses_id = Stuff::get_Courses($_SESSION['person_id']);
if (!empty($courses_id)) {
    foreach ($courses_id as $course_id) {
        $messages = Stuff::getMessages($course_id);
        //$studen_name = Persons::get_name($course_id);
        foreach ($messages as $message) {
            $s_id = $message['student_id'];
            $name = Persons::get_name($s_id);
            $question = $message['question'];
            echo '<div class="new">';
            echo '<h5 >' . $question . ' <a type="link" class="primary" data-toggle="modal" data-target="#ToStuff">Answer</a></h5>';
            echo '</div>';
            echo '<div class="modal fade" id="ToStuff" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">';
            echo '<div class="modal-dialog" role="document">';
            echo '<div class="modal-content">';
            echo '<div class="modal-header">';
            echo '<button type="button" class="close" data-dismiss="modal" aria-label="Close">';
            echo '<span aria-hidden="true">×</span>';
            echo '</button>';
            echo '<h4 class="modal-title" id="myModalLabel" style="color:black;">Answer to Question : ' . $question . ' By ' . $name . '</h4>';
            echo '</div>';
            echo '<div class="modal-body">';
            echo '<form class="form-horizontal" role="form" action="../../controllers/stuff_message.php" method ="post" >';
Esempio n. 26
0
      <div class="form-group">
        <label for="region"><?php 
echo Yii::t('common', 'Region');
?>
</label>
        <?php 
echo CHtml::dropDownList('region', $region, Region::getWCARegions(), array('class' => 'form-control'));
?>
      </div>
      <div class="form-group">
        <label for="Competition_year"><?php 
echo Yii::t('common', 'Gender');
?>
</label>
        <?php 
echo CHtml::dropDownList('gender', $gender, Persons::getGenders(), array('class' => 'form-control'));
?>
      </div>
      <?php 
foreach (Results::getRankingTypes() as $_type) {
    ?>
      <?php 
    echo CHtml::tag('button', array('type' => 'submit', 'name' => 'type', 'value' => $_type, 'class' => 'btn btn-' . ($type == $_type ? 'warning' : 'theme')), Yii::t('common', ucfirst($_type)));
    ?>
      <?php 
}
?>
    </div>
  <?php 
$this->endWidget();
?>
Esempio n. 27
0
 function loadPersons($persons = false)
 {
     if ($this->personsLoaded) {
         return false;
     }
     if ($persons !== false) {
         $pid = array();
         foreach ($persons as $person) {
             $pid[] = $person['id_person'];
         }
         Persons::getInstance()->getByIdsLoaded($pid);
     } else {
         // связи
         $query = 'SELECT `person_role`,`id_person` FROM `book_persons` WHERE `id_book`=' . $this->id;
         $persons = Database::sql2array($query, 'id_person');
         // профили
         $personProfiles = array();
         if (count($persons)) {
             $ids = array_keys($persons);
             Persons::getInstance()->getByIdsLoaded($ids);
         }
     }
     foreach ($persons as $person) {
         $personItem = Persons::getInstance()->getByIdLoaded($person['id_person']);
         if ($personItem->loaded) {
             $personProfiles[$person['id_person']] = $personItem->getListData();
             $personProfiles[$person['id_person']]['role'] = $person['person_role'];
             $personProfiles[$person['id_person']]['roleName'] = $this->getPersonRoleName($person['person_role']);
             $this->persons[] = $personProfiles[$person['id_person']];
         }
     }
     $this->personsLoaded = true;
 }
Esempio n. 28
0
    public static function getPersonsComments($id)
    {
        $data = array();
        $sql = '
			SELECT {{tree}}.* FROM {{tree}} 
			INNER JOIN ({{data}}
				INNER JOIN {{relations}} ON {{relations}}.id1={{data}}.id
			) ON {{data}}.tree={{tree}}.id
			WHERE {{relations}}.modul1=\'data\' AND {{relations}}.id2=' . $id . ' AND {{relations}}.modul2=\'tree\'
				AND {{data}}.path=\'newscom\'
			ORDER BY num
		';
        $list = DB::getAll($sql);
        foreach ($list as $item) {
            $fields = Fields::getFieldsByTree($item['id']);
            $item['preview'] = $fields['preview'];
            $item['person'] = Persons::getOne($item['parent']);
            $data[] = $item;
        }
        return $data;
    }
Esempio n. 29
0
 public static function buildPageTitlePart($var)
 {
     $x = explode(':', $var[1]);
     $name = false;
     if (count($x) == 3) {
         list($name, $paramtype, $paramvalue) = $x;
     }
     if (count($x) == 2) {
         list($name, $paramvalue) = $x;
         $paramtype = 'raw_get';
     }
     if ($name) {
         $val = self::parseParams($paramtype, $paramvalue);
         switch ($name) {
             case 'profile-nickname':
                 $user = Users::getByIdsLoaded(array((int) $val));
                 $user = isset($user[$val]) ? $user[$val] : false;
                 /* @var $user User */
                 if ($user) {
                     return $user->getNickName();
                 }
                 break;
             case 'book-title':
                 $book = Books::getInstance()->getByIdLoaded((int) $val);
                 /* @var $book Book */
                 return $book->getTitle(1);
                 break;
             case 'person-title':
                 $person = Persons::getInstance()->getById((int) $val);
                 /* @var $person Person */
                 return $person->getName();
                 break;
             case 'genre-title':
                 return Request::pass('genre-title');
                 break;
             case 'forum-title':
                 $t = Request::pass('forum-title');
                 if (!$t) {
                     $t = Database::sql2single('SELECT name FROM `term_data` WHERE `tid`=' . (int) $val);
                 }
                 return $t;
                 break;
             case 'post-subject':
                 return Request::pass('post-subject');
                 break;
             case 'theme-title':
                 return Request::pass('theme-title');
                 break;
             case 'serie-title':
                 $t = Request::pass('serie-title');
                 if (!$t) {
                     $t = Database::sql2single('SELECT `title` FROM `series` WHERE `id`=' . (int) $val);
                 }
                 return $t;
                 break;
             case 'shelf-name':
                 if ($val == 'loved') {
                     return 'Любимые книги';
                 }
                 if (isset(Config::$shelfIdByNames[$val])) {
                     return isset(Config::$shelves[Config::$shelfIdByNames[$val]]) ? Config::$shelves[Config::$shelfIdByNames[$val]] : $val;
                 }
                 break;
             case 'magazine-title':
                 $query = 'SELECT `title` FROM `magazines` WHERE `id`=' . (int) $val;
                 return Database::sql2single($query);
                 break;
             case 'thread-subject':
                 $query = 'SELECT `subject` FROM `users_messages` WHERE `id`=' . (int) $val;
                 return Database::sql2single($query);
                 break;
             case 'get':
                 return $val;
                 break;
             default:
                 throw new Exception('Cant process title part "' . $var[1] . '"');
                 break;
         }
     }
 }
Esempio n. 30
0
 public function __construct()
 {
     parent::__construct('suppliers');
 }