Esempio n. 1
0
 public function show()
 {
     $this->editable = UserHelper::isEditor();
     $cons = array();
     $field = trim(fRequest::get('field'));
     $start_year = trim(fRequest::get('start_year'));
     $major = trim(fRequest::get('major'));
     $location = trim(fRequest::get('location'));
     $words = trim(fRequest::get('words'));
     $cons['login_name|display_name~'] = $words;
     if (!empty($field)) {
         $cons['field='] = $field;
     }
     if (!empty($start_year)) {
         $cons['start_year='] = $start_year;
     }
     if (!empty($major)) {
         $cons['major='] = $major;
     }
     if (!empty($location)) {
         $cons['location~'] = $location;
     }
     $this->users = fRecordSet::build('Profile', $cons, array('id' => 'asc'));
     $this->field = $field;
     $this->start_year = $start_year;
     $this->major = $major;
     $this->location = $location;
     $this->words = $words;
     $this->render('search/index');
 }
Esempio n. 2
0
 public function delete($id)
 {
     try {
         $msg = new Msg($id);
         if (UserHelper::getProfileId() != $msg->getReceiver() and !UserHelper::isEditor()) {
             throw new fValidationException('not allowed');
         }
         $msg->delete();
         $this->ajaxReturn(array('result' => 'success'));
     } catch (fException $e) {
         $this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage()));
     }
 }
Esempio n. 3
0
 public function delete($id)
 {
     try {
         $users = new Name($id);
         if (!UserHelper::isEditor()) {
             throw new fValidationException('not allowed');
         }
         $users->delete();
         $this->ajaxReturn(array('result' => 'success'));
     } catch (fException $e) {
         $this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage()));
     }
 }
Esempio n. 4
0
    echo $tweet->getTimestamp()->getFuzzyDifference();
    ?>
</span>
        <a class="reply" href="javascript:void(0)">
          回复<?php 
    if ($cc = $tweet->getComments()->count()) {
        ?>
(<?php 
        echo $cc;
        ?>
)<?php 
    }
    ?>
        </a>
<?php 
    if (UserHelper::isEditor()) {
        ?>
<a class="delete-tweet" href="javascript:void(0)" data-tweet-id="<?php 
        echo $tweet->getId();
        ?>
" >
          删除</a>
<?php 
    }
    ?>
      </div>
    </div>
    <div class="comments">
      <?php 
    include __DIR__ . '/_comments.php';
    ?>
Esempio n. 5
0
 public function sendmail1()
 {
     try {
         if (!UserHelper::isEditor()) {
             throw fValidationException('not allowed');
         }
         $emails = json_decode(trim(fRequest::get('emails')));
         $title = trim(fRequest::get('title'));
         $content = trim(fRequest::get('content'));
         foreach ($emails as $email) {
             self::send($email, $title, $content);
         }
         $this->ajaxReturn(array('result' => 'success'));
     } catch (Exception $e) {
         $this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage()));
     }
 }
Esempio n. 6
0
 public function update($id)
 {
     try {
         $this->db = fORMDatabase::retrieve();
         $this->db->query('BEGIN');
         $profile = new Profile($id);
         if (UserHelper::getProfileId() != $profile->getId() and !UserHelper::isEditor()) {
             throw new fValidationException('not allowed');
         }
         $profile->setStartYear(fRequest::get('start_year'));
         $profile->setClassNumber(fRequest::get('class_number'));
         $profile->setStudentNumber(trim(fRequest::get('student_number')));
         $profile->setBirthday(trim(fRequest::get('birthday')));
         $profile->setGender(fRequest::get('gender'));
         //$profile->setLocation(trim(fRequest::get('location')));
         $province = trim(fRequest::get('province'));
         $city = trim(fRequest::get('city'));
         $profile->setLocation(self::formatLocation($province, $city));
         $profile->setPostNumber(trim(fRequest::get('post_number')));
         $profile->setPrivacyControl(trim(fRequest::get('privacy', 'int', 0)));
         $profile->setField(trim(fRequest::get('field')));
         $profile->setInstitute(trim(fRequest::get('institute')));
         $profile->setPosition(trim(fRequest::get('position')));
         $profile->setMajor(trim(fRequest::get('major')));
         $profile->setMentor(trim(fRequest::get('mentor')));
         $profile->setSubscription(trim(fRequest::get('subscription')));
         $profile->store();
         foreach ($profile->getContacts() as $contact) {
             $contact->delete();
         }
         foreach ($this->contact_types as $type) {
             if (strlen(trim(fRequest::get($type)))) {
                 $contact = new Contact();
                 $contact->setProfileId($profile->getId());
                 $contact->setType($type);
                 $contact->setContent(trim(fRequest::get($type)));
                 $contact->setCreatedAt(Util::currentTime());
                 $contact->store();
             }
         }
         $this->db->query('COMMIT');
         Activity::fireUpdateProfile();
         $this->ajaxReturn(array('result' => 'success', 'profile_id' => $profile->getId()));
     } catch (fException $e) {
         if (isset($this->db)) {
             $this->db->query('ROLLBACK');
         }
         $this->ajaxReturn(array('result' => 'failure', 'message' => $e->getMessage()));
     }
 }