Пример #1
0
 public function create()
 {
     try {
         $profileId = UserHelper::getProfileId();
         $tweet = new Tweet();
         $tweet->setProfileId($profileId);
         $tweet->setContent(trim(fRequest::get('tweet-content')));
         if (strlen($tweet->getContent()) < 1) {
             throw new fValidationException('微博长度不能少于1个字符');
         }
         if (strlen($tweet->getContent()) > 140) {
             throw new fValidationException('微博长度不能超过140个字符');
         }
         $tweet->store();
         Activity::fireNewTweet();
         fMessaging::create('success', 'create tweet', '成功发表新微博!');
     } catch (fException $e) {
         fMessaging::create('failure', 'create tweet', $e->getMessage());
     }
     if (fRequest::get('quick', 'boolean')) {
         fURL::redirect(SITE_BASE . '/tweets');
     } else {
         fURL::redirect(SITE_BASE . '/profile/' . $profileId);
     }
 }
Пример #2
0
 public function submit($problem_id)
 {
     try {
         $problem = new Problem($problem_id);
         $language = fRequest::get('language', 'integer');
         if (!array_key_exists($language, static::$languages)) {
             throw new fValidationException('Invalid language.');
         }
         fSession::set('last_language', $language);
         $code = trim(fRequest::get('code', 'string'));
         if (strlen($code) == 0) {
             throw new fValidationException('Code cannot be empty.');
         }
         if ($problem->isSecretNow()) {
             if (!User::can('view-any-problem')) {
                 throw new fAuthorizationException('Problem is secret now. You are not allowed to submit this problem.');
             }
         }
         $record = new Record();
         $record->setOwner(fAuthorization::getUserToken());
         $record->setProblemId($problem->getId());
         $record->setSubmitCode($code);
         $record->setCodeLanguage($language);
         $record->setSubmitDatetime(Util::currentTime());
         $record->setJudgeStatus(JudgeStatus::PENDING);
         $record->setJudgeMessage('Judging... PROB=' . $problem->getId() . ' LANG=' . static::$languages[$language]);
         $record->setVerdict(Verdict::UNKNOWN);
         $record->store();
         Util::redirect('/status');
     } catch (fException $e) {
         fMessaging::create('error', $e->getMessage());
         fMessaging::create('code', '/submit', fRequest::get('code', 'string'));
         Util::redirect("/submit?problem={$problem_id}");
     }
 }
Пример #3
0
 public function create()
 {
     try {
         $profileId = UserHelper::getProfileId();
         $msg = new Msg();
         $msg->setSender($profileId);
         $msg->setContent(trim(fRequest::get('msg-content')));
         $re = trim(fRequest::get('dest', 'integer'));
         $x = new Profile($re);
         $msg->setReceiver($re);
         if (strlen($msg->getContent()) < 1) {
             throw new fValidationException('信息长度不能少于1个字符');
         }
         if (strlen($msg->getContent()) > 140) {
             throw new fValidationException('信息长度不能超过140个字符');
         }
         $msg->store();
         //Activity::fireNewTweet();
         fMessaging::create('success', 'create msg', '留言成功!');
     } catch (fNotFoundException $e) {
         fMessaging::create('failure', 'create msg', '该用户名不存在!');
     } catch (fException $e) {
         fMessaging::create('failure', 'create msg', $e->getMessage());
     }
     fURL::redirect(SITE_BASE . '/profile/' . $re . '/msgs');
 }
Пример #4
0
 public static function requireEmailVerified()
 {
     if (!fAuthorization::checkLoggedIn()) {
         return;
     }
     if (User::hasEmailVerified()) {
         return;
     }
     fMessaging::create('warning', 'You are required to verify your email address before doing this action.');
     Util::redirect('/email/verify');
 }
Пример #5
0
 /**
  * Upload an image file for avatar
  */
 public function upload()
 {
     try {
         if (self::isImage($_FILES['avatar-file']) && move_uploaded_file($_FILES['avatar-file']['tmp_name'], $this->uploadfile)) {
             fURL::redirect(SITE_BASE . '/avatar/edit');
         } else {
             throw new fValidationException('上传图片失败');
         }
     } catch (Exception $e) {
         fMessaging::create('failure', 'upload avatar', $e->getMessage());
         fURL::redirect(SITE_BASE . '/profile/' . UserHelper::getProfileId());
     }
 }
Пример #6
0
 public function upload()
 {
     $uploadfile = UPLOAD_DIR . basename($_FILES['userfile']['name']);
     try {
         if (self::validFile($uploadfile) && move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
             fURL::redirect(SITE_BASE . '/manage');
         } else {
             throw new fValidationException('上传失败');
         }
     } catch (Exception $e) {
         fMessaging::create('failure', 'upload file', $e->getMessage());
         fURL::redirect(SITE_BASE . '/manage');
     }
 }
Пример #7
0
 public function show($id)
 {
     $this->cache_control('private', 2);
     try {
         $this->record = new Record($id);
         if (!$this->record->isReadable()) {
             throw new fAuthorizationException('You are not allowed to read this record.');
         }
         $this->nav_class = 'status';
         $this->render('record/show');
     } catch (fExpectedException $e) {
         fMessaging::create('warning', $e->getMessage());
         fURL::redirect(Util::getReferer());
     } catch (fUnexpectedException $e) {
         fMessaging::create('error', $e->getMessage());
         fURL::redirect(Util::getReferer());
     }
 }
Пример #8
0
 public function create()
 {
     try {
         $profileId = UserHelper::getProfileId();
         $mail = new Mail();
         $mail->setSender($profileId);
         $mail->setContent(trim(fRequest::get('mail-content')));
         $re = trim(fRequest::get('dest'));
         if (empty($re)) {
             $re = trim(fRequest::get('destre', 'integer'));
             $pa = trim(fRequest::get('parent', 'integer', -1));
             $x = new Profile($re);
             $mail->setReceiver($re);
             $mail->setParent($pa);
         } else {
             //$receiver=fRecordSet::build('Profile',array('login_name=' => $re ),array())->getRecord(0);
             $receiver = fRecordSet::build('Profile', array('login_name=' => $re), array());
             if ($receiver->count()) {
                 $receiver = $receiver->getRecord(0);
             } else {
                 throw new fNotFoundException('user doesn\'t exist');
             }
             $mail->setReceiver($receiver->getId());
         }
         if (strlen($mail->getContent()) < 1) {
             throw new fValidationException('信息长度不能少于1个字符');
         }
         if (strlen($mail->getContent()) > 140) {
             throw new fValidationException('信息长度不能超过140个字符');
         }
         $mail->store();
         //Activity::fireNewTweet();
         fMessaging::create('success', 'create mail', '信息发送成功!');
     } catch (fNotFoundException $e) {
         fMessaging::create('failure', 'create mail', '该用户名不存在,或该用户没有创建个人资料!');
     } catch (fException $e) {
         fMessaging::create('failure', 'create mail', $e->getMessage());
     }
     fURL::redirect(SITE_BASE . '/inbox');
 }
Пример #9
0
 public function show($id)
 {
     if (fAuthorization::checkLoggedIn()) {
         $this->cache_control('private', 30);
     } else {
         $this->cache_control('private', 60);
     }
     try {
         $this->problem = new Problem($id);
         if ($this->problem->isSecretNow()) {
             if (!User::can('view-any-problem')) {
                 throw new fAuthorizationException('Problem is secret now.');
             }
         }
         $this->nav_class = 'problems';
         $this->render('problem/show');
     } catch (fExpectedException $e) {
         fMessaging::create('warning', $e->getMessage());
         fURL::redirect(Util::getReferer());
     } catch (fUnexpectedException $e) {
         fMessaging::create('error', $e->getMessage());
         fURL::redirect(Util::getReferer());
     }
 }
Пример #10
0
        // Get objects matching the printer/consumable
        $consumable = new Consumable($consumable_id);
        // Update cost if present
        if ($cost) {
            $consumable->setCost($cost);
            $consumable->store();
        }
        // Update consumable
        $updated = $consumable->increaseStockBy($qty);
        #die(var_export($updated));
        // Check status of installation
        if ($updated == FALSE) {
            fMessaging::create('error', $redirect, $consumable->err);
            fURL::redirect($redirect);
        } else {
            fMessaging::create('success', $redirect, sprintf('The consumable stock for %s has been updated.', $consumable->getName()));
            fURL::redirect($redirect);
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', $redirect, 'The requested object with ID ' . $id . ', could not be found.');
        fURL::redirect($redirect);
    }
} else {
    // Get consumable object from ID
    if ($consumable_id != NULL) {
        $c = Consumable::getOne($consumable_id);
    }
    // No POSTed data, show form (based on request method)
    $view = fRequest::isAjax() ? 'ajax.php' : 'simple.php';
    include 'views/stock/' . $view;
}
Пример #11
0
 public function checkVericode($id, $vericode)
 {
     try {
         $v = new Vericode($id);
         if ($v->getUsername() != fAuthorization::getUserToken() or $v->getVericode() != $vericode) {
             throw new fValidationException('Invalid verification code.');
         }
         $ue = new UserEmail();
         $ue->setUsername($v->getUsername());
         $ue->setEmail($v->getEmail());
         $ue->store();
         fMessaging::create('success', 'Your email address is verified successfully.');
         $referer = fMessaging::retrieve('referer', SITE_BASE . '/email/verify');
         if ($referer == NULL) {
             $referer = SITE_BASE;
         }
         fURL::redirect($referer);
     } catch (fException $e) {
         fMessaging::create('error', 'Email verification failed: ' . $e->getMessage());
         Util::redirect('/email/verify');
     }
 }
Пример #12
0
 public static function array_to_dbentry($input, $class, $columns_to_ignore = NULL)
 {
     try {
         if (!empty($input)) {
             $new_dbentry = new $class();
             $has_at_least_one_column = false;
             foreach ($input as $column => $value) {
                 if (!empty($columns_to_ignore) && !in_array($column, $columns_to_ignore)) {
                     $new_dbentry->set($column, $value);
                     $has_at_least_one_column = true;
                 }
             }
             if ($has_at_least_one_column) {
                 return $new_dbentry;
             }
         }
     } catch (fProgrammerException $e) {
         $messages = fMessaging::retrieve('error', "/" . Dashboard::makeUrl('list'));
         if (!empty($messages)) {
             $messages .= "<br/>";
         } else {
             $messages = "";
         }
         fMessaging::create('error', "/" . Dashboard::makeUrl('list'), $messages . "An error occured by creating a new " . $class . " : " . $e->getMessage());
     }
     return NULL;
 }
Пример #13
0
    ?>
/reply" method="post" onsubmit="$.blockUI();">
    <?php 
    if ($artcom_success = fMessaging::retrieve('success', 'create article comment')) {
        ?>
      <div class="alert alert-success fade in">
        <a class="close" data-dismiss="alert">&times;</a>
        <?php 
        echo $artcom_success;
        ?>
      </div>
    <?php 
    }
    ?>
    <?php 
    if ($artcom_failure = fMessaging::retrieve('failure', 'create article comment')) {
        ?>
      <div class="alert alert-error fade in">
        <a class="close" data-dismiss="alert">&times;</a>
        <?php 
        echo $artcom_failure;
        ?>
      </div>
    <?php 
    }
    ?>
    <div class="controls">
      <button type="submit" class="btn btn-success btn-large pull-right">
        <i class="icon-comment icon-white"></i>
        发表评论
      </button>
Пример #14
0
        $array_of_weights = explode(",", $drag_order);
        $graphs_in_dashboard = array();
        foreach ($array_of_weights as $new_weight) {
            $expl = explode(":", $new_weight);
            $current_graph = new Graph($expl[0]);
            if (!isset($dashboard_id)) {
                $dashboard_id = $current_graph->getDashboardId();
            } else {
                // Check if all the graphs are in the same dashboard
                if ($dashboard_id != $current_graph->getDashboardId()) {
                    $error = true;
                    break;
                }
            }
            $current_graph->setWeight($expl[1]);
            $graphs_in_dashboard[] = $current_graph;
        }
    }
    if (!$error) {
        foreach ($graphs_in_dashboard as $graph_to_store) {
            $graph_to_store->store();
        }
        $dashboard = new Dashboard($dashboard_id);
        $url_redirect = Dashboard::makeURL('edit', $dashboard);
        fMessaging::create("success", "/dashboard.php", "The graphs have been successfully reordered");
    } else {
        $url_redirect = Dashboard::makeURL('list');
        fMessaging::create("success", "/dashboard.php", "An error occured and the graphs couldn't be reordered");
    }
    fURL::redirect($url_redirect);
}
Пример #15
0
?>
" />
	<input type="hidden" name="id" value="<?php 
echo $m->getId();
?>
" />

		<table class="form">

			<tr>
				<td class="caption"><label for="manufacturer_id">Manufacturer</label></td>
				<td class="input">
					<select name="manufacturer_id" id="manufacturer_id">
					<?php 
$option = '<option value="%d">%s</option>';
$selected = $action === 'add' ? fMessaging::retrieve('manufacturer_id', 'models/add') : $m->getManufacturerId();
foreach ($manufacturers as $mfr) {
    fHTML::printOption($mfr->getName(), $mfr->getId(), $selected);
}
?>
					</select>
				</td>
			</tr>

			<tr>
				<td class="caption"><label for="name">Name</label></td>
				<td class="input">
					<input id="name" type="text" name="name" value="<?php 
echo $m->getName();
?>
"
Пример #16
0
      <div class="failure" style="display:none"></div>
      <div class="action">
        <button type="submit" class="btn btn-success btn-large">保存</button>
      </div>
      <p class="clear"></p>
    </form>
  </div>
</div>
<script type="text/javascript">
  window.profileId = '<?php 
    echo $this->profile->getId();
    ?>
';
<?php 
    if ($failure = fMessaging::retrieve('failure', 'upload avatar')) {
        ?>
  window.uploadAvatar = { result: 'failure', message: '<?php 
        echo $failure;
        ?>
' };
<?php 
    } else {
        ?>
  window.uploadAvatar = { result: 'success' };
<?php 
    }
    ?>
</script>
<?php 
}
Пример #17
0
 public function toggleQuestionVisibility($id)
 {
     try {
         $question = new Question($id);
         $report = new Report($report_id = $question->getReportId());
         if (!$report->allowAnswer()) {
             throw new fValidationException('Not allowed to toggle question visibility.');
         }
         $question->setCategory(-$question->getCategory());
         $question->store();
         fMessaging::create('success', 'Visibility toggled.');
     } catch (fExpectedException $e) {
         fMessaging::create('warning', $e->getMessage());
     } catch (fUnexpectedException $e) {
         fMessaging::create('error', $e->getMessage());
     }
     Util::redirect("/contest/{$report_id}");
 }
Пример #18
0
 public static function import_from_json_to_group($json, $group_id = NULL)
 {
     $result = true;
     $json_array = json_decode($json, TRUE);
     if (!empty($json_array)) {
         if (array_key_exists("name", $json_array)) {
             // In this case, we only have a dashboard, not an array of dashboard
             // We convert it into an array
             $json_array = array($json_array);
         }
         foreach ($json_array as $dashboard_to_create) {
             $column_to_ignore = array('dashboard_id', 'group_id', 'graphs');
             $new_dashboard = fActiveRecord::array_to_dbentry($dashboard_to_create, __CLASS__, $column_to_ignore);
             if ($new_dashboard !== NULL) {
                 $new_dashboard->setGroupId(empty($group_id) ? $GLOBALS['DEFAULT_GROUP_ID'] : $group_id);
                 $new_dashboard->setUserId(fSession::get('user_id', 1));
                 $new_dashboard->store();
                 if (in_array('graphs', array_keys($dashboard_to_create))) {
                     $new_dashboard_id = $new_dashboard->getDashboardId();
                     foreach ($dashboard_to_create['graphs'] as $graph) {
                         $result_graph = Graph::import_from_array_to_dashboard($graph, $new_dashboard_id);
                         $result = $result && $result_graph;
                     }
                 }
             } else {
                 $result = false;
             }
         }
     } else {
         fMessaging::create('error', "/" . Dashboard::makeUrl('list'), "Empty or malformed file");
         $result = false;
     }
     return $result;
 }
Пример #19
0
}
if (fMessaging::check('error')) {
    ?>
<div class="alert alert-error">
  <a class="close" data-dismiss="alert">&times;</a>
  <strong>Oh snap!</strong> <?php 
    echo fMessaging::retrieve('error');
    ?>
</div>
<?php 
}
if (fMessaging::check('success')) {
    ?>
<div class="alert alert-success">
  <a class="close" data-dismiss="alert">&times;</a>
  <strong>Well done!</strong> <?php 
    echo fMessaging::retrieve('success');
    ?>
</div>
<?php 
}
if (fMessaging::check('info')) {
    ?>
<div class="alert alert-info">
  <a class="close" data-dismiss="alert">&times;</a>
  <strong>Heads up!</strong> <?php 
    echo fMessaging::retrieve('info');
    ?>
</div>
<?php 
}
Пример #20
0
/tweets" method="post" onsubmit="$.blockUI();">
      <input type="hidden" name="quick" value="true"/>
      <?php 
    if ($tweet_success = fMessaging::retrieve('success', 'create tweet')) {
        ?>
        <div class="alert alert-success fade in">
          <a class="close" data-dismiss="alert">&times;</a>
          <?php 
        echo $tweet_success;
        ?>
        </div>
      <?php 
    }
    ?>
      <?php 
    if ($tweet_failure = fMessaging::retrieve('failure', 'create tweet')) {
        ?>
        <div class="alert alert-error fade in">
          <a class="close" data-dismiss="alert">&times;</a>
          <?php 
        echo $tweet_failure;
        ?>
        </div>
      <?php 
    }
    ?>
      <div class="controls">
        <input name="tweet-content" type="text" class="span6 input-xlarge" maxlength="140" placeholder="说点什么吧⋯⋯"/>
        <button type="submit" class="btn btn-danger btn-large">发表新微博</button>
      </div>
    </form>
Пример #21
0
?>
</h1>

<p class="nav">
	<a href="<?php 
echo Check::makeURL('list');
?>
">List all checks</a> |
	<a class="related" href="<?php 
echo Check::makeURL('edit', $check);
?>
">Edit this check</a>
</p>

<?php 
fMessaging::show('error', fURL::get());
?>

<form action="<?php 
echo Check::makeURL('delete', $check);
?>
" method="post">
	
	<p class="warning">
		Are you sure you want to delete the check
		<strong><?php 
echo $check->prepareTitle();
?>
</strong>?
	</p>
	
Пример #22
0
 /**
  * Configures a class to be present in all messages when no custom css class is given
  *
  * @param  string $class  A class for all messages
  * @return void
  */
 public static function setClass($class)
 {
     self::$class = $class;
 }
Пример #23
0
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Content-Type: application/force-download");
        header("Content-Type: application/octet-stream");
        header("Content-Type: application/download");
        header("Content-Disposition: attachment; filename=\"" . $json_name . "\"");
        header("Content-Transfer-Encoding: binary");
        echo $json_to_send, "\n";
    }
} elseif ('import' == $action) {
    if (isset($_FILES['uploadedfile']['tmp_name']) && $_FILES['uploadedfile']['error'] == UPLOAD_ERR_OK) {
        $file = $_FILES['uploadedfile']['tmp_name'];
        $content = fread(fopen($file, "r"), filesize($file));
        $filter_group_id = $_POST['filter_group_id'];
        if ($filter_group_id < 0) {
            $result_ok = Dashboard::import_from_json_to_group($content);
        } else {
            $result_ok = Dashboard::import_from_json_to_group($content, $filter_group_id);
        }
        if ($result_ok) {
            fMessaging::create('success', "/" . Dashboard::makeUrl('list'), 'The Dashboard was successfully imported');
        }
    }
    fURL::redirect(Dashboard::makeUrl('list', $filter_group_id));
} else {
    if ($filter_group_id == -1) {
        $dashboards = Dashboard::findAll();
    } else {
        $dashboards = Dashboard::findAllByFilter($filter_group_id);
    }
    include VIEW_PATH . '/list_dashboards.php';
}
Пример #24
0
    // Get list of models
    $models = Model::getSimple($db);
    // Get types
    if (feature('consumable_types')) {
        $types = Tag::get_by_type('consumable_type');
    }
    include 'views/consumables/addedit.php';
}
/**
 * Delete a consumable
 */
if ($action == 'delete') {
    // Get ID
    $id = fRequest::get('id', 'integer');
    try {
        $c = new Consumable($id);
        if (fRequest::isPost()) {
            $c->delete();
            fMessaging::create('success', fURL::get(), 'The consumable ' . $c->getName() . ' was successfully deleted.');
            fURL::redirect(fURL::get());
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', fURL::get(), 'The consumable requested, ID ' . $id . ', could not be found.');
        fURL::redirect($manage_url);
    } catch (fExpectedException $e) {
        fMessaging::create('error', fURL::get(), $e->getMessage());
    } catch (fSQLException $e) {
        fMessaging::create('error', fURL::get(), 'Database error: ' . $e->getMessage());
    }
    include 'views/consumables/delete.php';
}
Пример #25
0
$tmpl->set('title', 'Self Service Alerts based on Graphite metrics');
$active_tab_alerts = " class=active";
$tmpl->set('breadcrumbs', $breadcrumbs);
$tmpl->place('header');
?>
<script type="text/javascript">
$(function(){
	$('#list_of_filters').change(function(){
		$(location).attr('href',$('#list_of_filters').val());
	});
});
</script>
<?php 
try {
    $checks->tossIfEmpty();
    $affected = fMessaging::retrieve('affected', fURL::get());
    ?>

<script type="text/javascript">
    function filterChecks() {
            var filter_text = $("#filter_text").val();
            var type = '<?php 
    echo $check_type;
    ?>
';
            var filter_group_id = <?php 
    echo $filter_group_id;
    ?>
;
            $.get(
                'inc/views/list_filtered_checks.php', 
Пример #26
0
$over_under_array = array('0' => 'Over', '1' => 'Under');
$breadcrumbs = array();
$breadcrumbs[] = array('name' => 'Home', 'url' => '#', 'active' => false);
error_reporting(E_STRICT | E_ALL);
fCore::enableErrorHandling('html');
fCore::enableExceptionHandling('html');
fTimestamp::setDefaultTimezone($GLOBALS['TIMEZONE']);
fAuthorization::setLoginPage(User::makeURL('login'));
fAuthorization::setAuthLevels(array('admin' => 100, 'user' => 50, 'guest' => 25));
// This prevents cross-site session transfer
fSession::setPath($GLOBALS['SESSION_FILES']);
if (!fAuthorization::checkLoggedIn()) {
    if ($GLOBALS['ALLOW_HTTP_AUTH'] && (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']))) {
        unset($_SERVER['PHP_AUTH_PW']);
        //no need for a clear text password hanging around.
        try {
            $user = new User(array('username' => $_SERVER['PHP_AUTH_USER']));
            // Auto Register User
            fAuthorization::setUserToken($user->getEmail());
            fAuthorization::setUserAuthLevel($user->getRole());
            fSession::set('user_id', $user->getUserId());
            fSession::set('user_name', $user->getUsername());
        } catch (fNotFoundException $e) {
            if (fURL::getWithQueryString() != TATTLE_WEB_ROOT . User::makeURL('add')) {
                fMessaging::create('affected', User::makeURL('add'), $_SERVER['PHP_AUTH_USER']);
                fMessaging::create('success', User::makeURL('add'), 'The user ' . $_SERVER['PHP_AUTH_USER'] . ' was successfully created');
                fURL::redirect(User::makeURL('add'));
            }
        }
    }
}
Пример #27
0
        </div>
      </div>
<?php 
}
?>
<div class="container-fluid">
<?php 
$breadcrumbs = $this->get('breadcrumbs');
if (is_array($breadcrumbs)) {
    echo '<ul class="breadcrumb">';
    $crumb_count = count($breadcrumbs);
    $crumb_counter = 1;
    foreach ($breadcrumbs as $crumb) {
        echo '<li' . (isset($crumb['class']) ? ' class="' . $crumb['class'] . '"' : ' class="active"') . '><a href="' . $crumb['url'] . '">' . $crumb['name'] . '</a>';
        if ($crumb_counter < $crumb_count) {
            echo '<span class="divider">/</span></li>';
        }
        $crumb_counter++;
    }
    echo '</ul>';
}
if (fMessaging::check('error', fURL::get())) {
    echo '<div class="alert-message error">';
    fMessaging::show('error', fURL::get());
    echo '</div>';
}
if (fMessaging::check('success', fURL::get())) {
    echo '<div class="alert-message success">';
    fMessaging::show('success', fURL::get());
    echo '</div>';
}
Пример #28
0
 public function reply($id)
 {
     try {
         $article = new Article($id);
         $comment = new ArticleComment();
         $comment->setArticleId($article->getId());
         $comment->setProfileId(UserHelper::getProfileId());
         $comment->setContent(trim(fRequest::get('article-comment')));
         if (strlen($comment->getContent()) < 1) {
             throw new fValidationException('回复长度不能少于1个字符');
         }
         if (strlen($comment->getContent()) > 240) {
             throw new fValidationException('回复长度不能超过240个字符');
         }
         $comment->store();
         fMessaging::create('success', 'create article comment', '成功发表评论!');
         fURL::redirect(SITE_BASE . '/article/' . $id . '#comment-' . $comment->getId());
     } catch (fException $e) {
         fMessaging::create('failure', 'create article comment', $e->getMessage());
         fURL::redirect(SITE_BASE . '/article/' . $id . '#comment-form');
     }
 }
Пример #29
0
                    foreach ($subscriptions as $sub) {
                        $user_id = $sub['user_id'];
                        if (!in_array($user_id, $alt_ids) && $user_id != $id_user_session) {
                            $user = new User($sub['user_id']);
                            $recipients[] = array("mail" => $user->getEmail(), "name" => $user->getUsername());
                        }
                    }
                    if (!empty($recipients)) {
                        // Send the mail to everybody
                        notify_multiple_users($user_session, $recipients, $subject_mail, $content_mail);
                        fMessaging::create('success', fURL::get(), 'The mail "' . $subject_mail . '" was successfully sent to all the users who subscribe to "' . $check->getName() . '"');
                    } else {
                        fMessaging::create('error', fURL::get(), "Nobody subscribe to this check");
                    }
                }
            }
        } catch (fNotFoundException $e) {
            fMessaging::create('error', $manage_url, 'The check requested, ' . fHTML::encode($check_id) . ', could not be found');
            fURL::redirect($manage_url);
        } catch (fExpectedException $e) {
            fMessaging::create('error', fURL::get(), $e->getMessage());
        }
        $page_num = fRequest::get('page', 'int', 1);
        $url_redirect = CheckResult::makeURL('list', $check) . "&page=" . $page_num;
        fURL::redirect($url_redirect);
    } else {
        $page_num = fRequest::get('page', 'int', 1);
        $check_results = CheckResult::findAll($check_id, false, $GLOBALS['PAGE_SIZE'], $page_num);
        include VIEW_PATH . '/list_check_results.php';
    }
}
Пример #30
0
 public function setVariable()
 {
     try {
         if (fRequest::get('remove', 'boolean')) {
             $variable = new Variable(fRequest::get('name'));
             $variable->delete();
             fMessaging::create('success', 'Variable removed successfully.');
         } else {
             try {
                 $variable = new Variable(fRequest::get('name'));
             } catch (fNotFoundException $e) {
                 $variable = new Variable();
                 $variable->setName(fRequest::get('name'));
             }
             $variable->setValue(fRequest::get('value'));
             $variable->store();
             fMessaging::create('success', 'Variable set successfully.');
         }
     } catch (fException $e) {
         fMessaging::create('error', $e->getMessage());
     }
     fURL::redirect(Util::getReferer());
 }