本文整理汇总了PHP中Message::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::getId方法的具体用法?PHP Message::getId怎么用?PHP Message::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::getId方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetId
public function testSetId()
{
$msg = new Message();
$msg->setId('foo');
$this->assertEquals('foo', $msg->getId());
$this->assertEquals(['apns-id' => 'foo'], $msg->getMessageHeaders());
}
示例2: testSetGet
public function testSetGet()
{
$now = new \DateTime();
$testCase = ['id' => 123, 'level' => 2, 'subject' => 'TEST SUBJECT', 'message' => 'TEST MESSAGE', 'source' => 'TEST_SOURCE', 'dateCreated' => $now, 'dateCreatedString' => $now->format(\DateTime::ISO8601)];
$unit = new Message();
$unit->setId($testCase['id']);
$this->assertEquals($testCase['id'], $unit->getId());
$unit->setLevel(0);
$this->assertEquals(Message::LEVEL_DEFAULT, $unit->getLevel());
$unit->setLevel($testCase['level']);
$this->assertEquals($testCase['level'], $unit->getLevel());
$unit->setSubject($testCase['subject']);
$this->assertEquals($testCase['subject'], $unit->getSubject());
$unit->setMessage($testCase['message']);
$this->assertEquals($testCase['message'], $unit->getMessage());
$unit->setSource('');
$this->assertNull($unit->getSource());
$unit->setSource($testCase['source']);
$this->assertEquals($testCase['source'], $unit->getSource());
$unit->setDateCreated(null);
$this->assertNull($unit->getDateCreatedString());
$unit->setDateCreated($testCase['dateCreated']);
$this->assertEquals($testCase['dateCreated'], $unit->getDateCreated());
$unit->setDateCreatedString($testCase['dateCreatedString']);
$this->assertEquals($testCase['dateCreatedString'], $unit->getDateCreatedString());
$this->assertEquals($testCase['id'], $unit->toArray()['id']);
$this->assertTrue(is_array($unit->toArray()));
}
示例3: transform
/**
* Transforms an object into an elastica object
*
* @param \Message $message the object to convert
* @param array $fields the keys we want to have in the returned array
*
* @return Document
**/
public function transform($message, array $fields = array())
{
$data = array('content' => $message->getContent());
$document = new Document($message->getId(), $data);
$document->setParent($message->getGroup()->getId());
return $document;
}
示例4: has
/**
* @param Message $message
* @return Boolean
*/
public function has(Message $message)
{
if (!$this->hasDomain($message->getDomain())) {
return false;
}
return $this->getDomain($message->getDomain())->has($message->getId());
}
示例5: testMessageConstructorWithString
public function testMessageConstructorWithString()
{
$message = new Message('test');
$this->assertSame(['body' => 'test'], $message->getData());
$this->assertSame([], $message->getMetadata());
$this->assertNull($message->getId());
$this->assertNull($message->getPriority());
$this->assertNull($message->getDelay());
}
示例6: delete
public function delete(Message $message)
{
$id = $message->getId();
$query = 'DELETE FROM message WHERE id = ' . $id;
$res = $this->db->exec($query);
if ($res) {
return true;
} else {
throw new Exception('Error 07 : Database error');
}
}
示例7: addInstanceToPool
/**
* Adds an object to the instance pool.
*
* Propel keeps cached copies of objects in an instance pool when they are retrieved
* from the database. In some cases -- especially when you override doSelect*()
* methods in your stub classes -- you may need to explicitly add objects
* to the cache in order to ensure that the same objects are always returned by doSelect*()
* and retrieveByPK*() calls.
*
* @param Message $value A Message object.
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
*/
public static function addInstanceToPool(Message $obj, $key = null)
{
if (Propel::isInstancePoolingEnabled()) {
if ($key === null) {
$key = (string) $obj->getId();
}
// if key === null
self::$instances[$key] = $obj;
}
}
示例8: remove
/**
* Removes a finished message from the queue.
*
* @param Message $message The message to remove.
*
* @return boolean Whether the message has been sucessfully removed.
*/
public function remove(Message $message)
{
$this->executeStatement($this->removeMessageStatement, [$message->getId()]);
return $this->removeMessageStatement->rowCount() != 0;
}
示例9: updateMessage
/**
* Update one Message in the database
*
* @author Jonathan Sandoval <jonathan_s_pisis@yahoo.com.mx>
* @param Message $Message The Message to update
* @return boolean If was possible to update
*/
static function updateMessage($Message = null)
{
if ($Message === null) {
return false;
}
$tableMessage = DatabaseManager::getNameTable('TABLE_MESSAGE');
$id = $Message->getId();
$seen = $Message->getSeen();
$query = "UPDATE {$tableMessage}\r\n SET seen = {$seen}\r\n WHERE {$tableMessage}.id = {$id}";
return DatabaseManager::singleAffectedRow($query);
}
示例10: lookup
function lookup($id, $tid = 0, $type = 'M')
{
return $id && is_numeric($id) && ($m = new Message($id, $tid)) && $m->getId() == $id ? $m : null;
}
示例11: testGetSetId
public function testGetSetId()
{
$message = new Message();
$message->setId(1);
$this->assertEquals(1, $message->getId());
}
示例12: log
/**
* Log information related to a message in the database.
*
* @param Message $message Message containing the log.
* @param string $log The log to store.
*
* @return bool PDO execution status.
*/
public function log(Message $message, $log)
{
$mid = $message->getId();
if (empty($mid) || !is_int($mid)) {
throw new \InvalidArgumentException('Could log into this message because its ID is empty or invalid');
}
$sql = 'UPDATE ' . self::TABLE_MESSAGE . ' SET log = :log WHERE id_message = :id';
$sth = $this->getDb()->prepare($sql);
$sth->bindValue(':id', $mid, \PDO::PARAM_INT);
$sth->bindValue(':log', $log);
return $sth->execute();
}
示例13: write_action
/**
* Lets the user compose a message and send it.
*/
public function write_action()
{
PageLayout::setTitle(_("Neue Nachricht schreiben"));
//collect possible default adressees
$this->to = array();
$this->default_message = new Message();
if (Request::username("rec_uname")) {
$user = new MessageUser();
$user->setData(array('user_id' => get_userid(Request::username("rec_uname")), 'snd_rec' => "rec"));
$this->default_message->receivers[] = $user;
}
if (Request::getArray("rec_uname")) {
foreach (Request::usernameArray("rec_uname") as $username) {
$user = new MessageUser();
$user->setData(array('user_id' => get_userid($username), 'snd_rec' => "rec"));
$this->default_message->receivers[] = $user;
}
}
if (Request::option("group_id")) {
$this->default_message->receivers = array();
$group = Statusgruppen::find(Request::option("group_id"));
if ($group['range_id'] === $GLOBALS['user']->id || $GLOBALS['perm']->have_studip_perm("autor", $group['range_id'])) {
foreach ($group->members as $member) {
$user = new MessageUser();
$user->setData(array('user_id' => $member['user_id'], 'snd_rec' => "rec"));
$this->default_message->receivers[] = $user;
}
}
}
if (Request::get('inst_id') && $GLOBALS['perm']->have_perm('admin')) {
$query = "SELECT user_id FROM user_inst WHERE Institut_id = ? AND inst_perms != 'user'";
$this->default_message->receivers = DBManager::get()->fetchAll($query, array(Request::option('inst_id')), 'MessageUser::build');
}
if (Request::get("filter") && Request::option("course_id")) {
$course = new Course(Request::option('course_id'));
if ($GLOBALS['perm']->have_studip_perm("tutor", Request::option('course_id')) || $course->getSemClass()['studygroup_mode']) {
$this->default_message->receivers = array();
if (Request::get("filter") === 'claiming') {
$cs = CourseSet::getSetForCourse(Request::option("course_id"));
if (is_object($cs) && !$cs->hasAlgorithmRun()) {
foreach (AdmissionPriority::getPrioritiesByCourse($cs->getId(), Request::option("course_id")) as $user_id => $p) {
$this->default_message->receivers[] = MessageUser::build(array('user_id' => $user_id, 'snd_rec' => 'rec'));
}
}
} else {
$params = array(Request::option('course_id'), Request::option('who'));
switch (Request::get("filter")) {
case 'send_sms_to_all':
$query = "SELECT b.user_id,'rec' as snd_rec FROM seminar_user a, auth_user_md5 b WHERE a.Seminar_id = ? AND a.user_id = b.user_id AND a.status = ? ORDER BY Nachname, Vorname";
break;
case 'all':
$query = "SELECT user_id,'rec' as snd_rec FROM seminar_user LEFT JOIN auth_user_md5 USING(user_id) WHERE Seminar_id = ? ORDER BY Nachname, Vorname";
break;
case 'prelim':
$query = "SELECT user_id,'rec' as snd_rec FROM admission_seminar_user LEFT JOIN auth_user_md5 USING(user_id) WHERE seminar_id = ? AND status='accepted' ORDER BY Nachname, Vorname";
break;
case 'awaiting':
$query = "SELECT user_id,'rec' as snd_rec FROM admission_seminar_user LEFT JOIN auth_user_md5 USING(user_id) WHERE seminar_id = ? AND status='awaiting' ORDER BY Nachname, Vorname";
break;
case 'inst_status':
$query = "SELECT b.user_id,'rec' as snd_rec FROM user_inst a, auth_user_md5 b WHERE a.Institut_id = ? AND a.user_id = b.user_id AND a.inst_perms = ? ORDER BY Nachname, Vorname";
break;
}
$this->default_message->receivers = DBManager::get()->fetchAll($query, $params, 'MessageUser::build');
}
}
}
if (Request::option('prof_id') && Request::option('deg_id') && $GLOBALS['perm']->have_perm('root')) {
$query = "SELECT DISTINCT user_id,'rec' as snd_rec\n FROM user_studiengang\n WHERE studiengang_id = ? AND abschluss_id = ?";
$this->default_message->receivers = DBManager::get()->fetchAll($query, array(Request::option('prof_id'), Request::option('deg_id')), 'MessageUser::build');
}
if (Request::option('sd_id') && $GLOBALS['perm']->have_perm('root')) {
$query = "SELECT DISTINCT user_id,'rec' as snd_rec\n FROM user_studiengang\n WHERE abschluss_id = ?";
$this->default_message->receivers = DBManager::get()->fetchAll($query, array(Request::option('sd_id')), 'MessageUser::build');
}
if (Request::option('sp_id') && $GLOBALS['perm']->have_perm('root')) {
$query = "SELECT DISTINCT user_id,'rec' as snd_rec\n FROM user_studiengang\n WHERE studiengang_id = ?";
$this->default_message->receivers = DBManager::get()->fetchAll($query, array(Request::option('sp_id')), 'MessageUser::build');
}
if (!$this->default_message->receivers->count() && is_array($_SESSION['sms_data']['p_rec'])) {
$this->default_message->receivers = DBManager::get()->fetchAll("SELECT user_id,'rec' as snd_rec FROM auth_user_md5 WHERE username IN(?) ORDER BY Nachname,Vorname", array($_SESSION['sms_data']['p_rec']), 'MessageUser::build');
unset($_SESSION['sms_data']);
}
if (Request::option("answer_to")) {
$this->default_message->receivers = array();
$old_message = new Message(Request::option("answer_to"));
if (!$old_message->permissionToRead()) {
throw new AccessDeniedException("Message is not for you.");
}
if (!Request::get('forward')) {
if (Request::option("quote") === $old_message->getId()) {
if (Studip\Markup::isHtml($old_message['message'])) {
$this->default_message['message'] = "<div>[quote]\n" . $old_message['message'] . "\n[/quote]</div>";
} else {
$this->default_message['message'] = "[quote]\n" . $old_message['message'] . "\n[/quote]";
}
}
//.........这里部分代码省略.........
示例14: prune
/**
* Exclude object from result
*
* @param Message $message Object to remove from the list of results
*
* @return MessageQuery The current query, for fluid interface
*/
public function prune($message = null)
{
if ($message) {
$this->addUsingAlias(MessagePeer::ID, $message->getId(), Criteria::NOT_EQUAL);
}
return $this;
}