2011-04-14 00:15:48 +02:00
|
|
|
<?php
|
|
|
|
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
final class PhabricatorFileImageMacro extends PhabricatorFileDAO
|
2013-02-17 15:37:09 +01:00
|
|
|
implements
|
|
|
|
PhabricatorSubscribableInterface,
|
Adding some filters and queries to Macro application
Summary:
Fixes T2778
Introduces `PhabricatorMacroQuery`, which should consolidate all queries regarding macros
Adds `PolicyInterface` to `PhabricatorImageMacro`, as else the query would fail (we should consider adding it to the ApplicationTransaction instead, if that was ever planned)
Adds `Active Macros` filter, making it the default
Adds `My Macros` filter. You may ask why it overwrites `$authors`. Well, I did not want the page jump to the conclusion that it is a search result. It //is// one more or less, but the filter would jump to `seach` instead of `my`. If you want `My Macros` removed, tell me. It is useful only to heavy-macro-uploaders-and-users though. Five or six people in `http://secure.phabricator.(org|com)`, and an estimated dozen and a half at bigger installs.
Test Plan: created multiple macros from multiple authors, disabled them at will. browsed around, verified that Macros only appeared in the right filters and that nothing else broke.
Reviewers: epriestley, chad, btrahan
CC: aran, Korvin
Maniphest Tasks: T2778
Differential Revision: https://secure.phabricator.com/D5409
2013-03-22 17:46:21 +01:00
|
|
|
PhabricatorApplicationTransactionInterface,
|
2013-10-25 21:52:00 +02:00
|
|
|
PhabricatorFlaggableInterface,
|
2015-07-27 16:51:37 +02:00
|
|
|
PhabricatorTokenReceiverInterface,
|
Adding some filters and queries to Macro application
Summary:
Fixes T2778
Introduces `PhabricatorMacroQuery`, which should consolidate all queries regarding macros
Adds `PolicyInterface` to `PhabricatorImageMacro`, as else the query would fail (we should consider adding it to the ApplicationTransaction instead, if that was ever planned)
Adds `Active Macros` filter, making it the default
Adds `My Macros` filter. You may ask why it overwrites `$authors`. Well, I did not want the page jump to the conclusion that it is a search result. It //is// one more or less, but the filter would jump to `seach` instead of `my`. If you want `My Macros` removed, tell me. It is useful only to heavy-macro-uploaders-and-users though. Five or six people in `http://secure.phabricator.(org|com)`, and an estimated dozen and a half at bigger installs.
Test Plan: created multiple macros from multiple authors, disabled them at will. browsed around, verified that Macros only appeared in the right filters and that nothing else broke.
Reviewers: epriestley, chad, btrahan
CC: aran, Korvin
Maniphest Tasks: T2778
Differential Revision: https://secure.phabricator.com/D5409
2013-03-22 17:46:21 +01:00
|
|
|
PhabricatorPolicyInterface {
|
2011-04-14 00:15:48 +02:00
|
|
|
|
2013-05-30 00:05:44 +02:00
|
|
|
protected $authorPHID;
|
2011-04-14 00:15:48 +02:00
|
|
|
protected $filePHID;
|
|
|
|
protected $name;
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
protected $isDisabled = 0;
|
2013-09-28 01:01:37 +02:00
|
|
|
protected $audioPHID;
|
|
|
|
protected $audioBehavior = self::AUDIO_BEHAVIOR_NONE;
|
2014-01-06 21:17:23 +01:00
|
|
|
protected $mailKey;
|
2011-04-14 00:15:48 +02:00
|
|
|
|
2013-09-03 15:02:14 +02:00
|
|
|
private $file = self::ATTACHABLE;
|
2013-09-28 01:01:37 +02:00
|
|
|
private $audio = self::ATTACHABLE;
|
|
|
|
|
|
|
|
const AUDIO_BEHAVIOR_NONE = 'audio:none';
|
|
|
|
const AUDIO_BEHAVIOR_ONCE = 'audio:once';
|
|
|
|
const AUDIO_BEHAVIOR_LOOP = 'audio:loop';
|
Adding some filters and queries to Macro application
Summary:
Fixes T2778
Introduces `PhabricatorMacroQuery`, which should consolidate all queries regarding macros
Adds `PolicyInterface` to `PhabricatorImageMacro`, as else the query would fail (we should consider adding it to the ApplicationTransaction instead, if that was ever planned)
Adds `Active Macros` filter, making it the default
Adds `My Macros` filter. You may ask why it overwrites `$authors`. Well, I did not want the page jump to the conclusion that it is a search result. It //is// one more or less, but the filter would jump to `seach` instead of `my`. If you want `My Macros` removed, tell me. It is useful only to heavy-macro-uploaders-and-users though. Five or six people in `http://secure.phabricator.(org|com)`, and an estimated dozen and a half at bigger installs.
Test Plan: created multiple macros from multiple authors, disabled them at will. browsed around, verified that Macros only appeared in the right filters and that nothing else broke.
Reviewers: epriestley, chad, btrahan
CC: aran, Korvin
Maniphest Tasks: T2778
Differential Revision: https://secure.phabricator.com/D5409
2013-03-22 17:46:21 +01:00
|
|
|
|
|
|
|
public function attachFile(PhabricatorFile $file) {
|
|
|
|
$this->file = $file;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFile() {
|
2013-09-03 15:02:14 +02:00
|
|
|
return $this->assertAttached($this->file);
|
Adding some filters and queries to Macro application
Summary:
Fixes T2778
Introduces `PhabricatorMacroQuery`, which should consolidate all queries regarding macros
Adds `PolicyInterface` to `PhabricatorImageMacro`, as else the query would fail (we should consider adding it to the ApplicationTransaction instead, if that was ever planned)
Adds `Active Macros` filter, making it the default
Adds `My Macros` filter. You may ask why it overwrites `$authors`. Well, I did not want the page jump to the conclusion that it is a search result. It //is// one more or less, but the filter would jump to `seach` instead of `my`. If you want `My Macros` removed, tell me. It is useful only to heavy-macro-uploaders-and-users though. Five or six people in `http://secure.phabricator.(org|com)`, and an estimated dozen and a half at bigger installs.
Test Plan: created multiple macros from multiple authors, disabled them at will. browsed around, verified that Macros only appeared in the right filters and that nothing else broke.
Reviewers: epriestley, chad, btrahan
CC: aran, Korvin
Maniphest Tasks: T2778
Differential Revision: https://secure.phabricator.com/D5409
2013-03-22 17:46:21 +01:00
|
|
|
}
|
|
|
|
|
2013-09-28 01:01:37 +02:00
|
|
|
public function attachAudio(PhabricatorFile $audio = null) {
|
|
|
|
$this->audio = $audio;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAudio() {
|
|
|
|
return $this->assertAttached($this->audio);
|
|
|
|
}
|
|
|
|
|
2017-05-03 20:11:14 +02:00
|
|
|
public static function initializeNewFileImageMacro(PhabricatorUser $actor) {
|
|
|
|
$macro = id(new self())
|
|
|
|
->setAuthorPHID($actor->getPHID());
|
|
|
|
return $macro;
|
|
|
|
}
|
|
|
|
|
2015-01-13 20:47:05 +01:00
|
|
|
protected function getConfiguration() {
|
2011-04-14 00:15:48 +02:00
|
|
|
return array(
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
self::CONFIG_AUX_PHID => true,
|
2014-09-19 14:44:40 +02:00
|
|
|
self::CONFIG_COLUMN_SCHEMA => array(
|
Fix almost all remaining schemata issues
Summary:
Ref T1191. This fixes nearly every remaining blocker for utf8mb4 -- primarily, overlong keys.
Remaining issue is https://secure.phabricator.com/T1191#77467
Test Plan: I'll annotate inline.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley, hach-que
Maniphest Tasks: T6099, T6129, T6133, T6134, T6150, T6148, T6147, T6146, T6105, T1191
Differential Revision: https://secure.phabricator.com/D10601
2014-10-01 17:18:36 +02:00
|
|
|
'name' => 'text128',
|
2014-09-19 14:44:40 +02:00
|
|
|
'authorPHID' => 'phid?',
|
|
|
|
'isDisabled' => 'bool',
|
|
|
|
'audioPHID' => 'phid?',
|
|
|
|
'audioBehavior' => 'text64',
|
|
|
|
'mailKey' => 'bytes20',
|
|
|
|
),
|
|
|
|
self::CONFIG_KEY_SCHEMA => array(
|
|
|
|
'name' => array(
|
|
|
|
'columns' => array('name'),
|
2014-10-01 16:53:50 +02:00
|
|
|
'unique' => true,
|
|
|
|
),
|
|
|
|
'key_disabled' => array(
|
|
|
|
'columns' => array('isDisabled'),
|
|
|
|
),
|
|
|
|
'key_dateCreated' => array(
|
|
|
|
'columns' => array('dateCreated'),
|
2014-09-19 14:44:40 +02:00
|
|
|
),
|
|
|
|
),
|
2011-04-14 00:15:48 +02:00
|
|
|
) + parent::getConfiguration();
|
|
|
|
}
|
|
|
|
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
public function generatePHID() {
|
|
|
|
return PhabricatorPHID::generateNewPHID(
|
2014-07-24 00:05:46 +02:00
|
|
|
PhabricatorMacroMacroPHIDType::TYPECONST);
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
}
|
|
|
|
|
2014-01-06 21:17:23 +01:00
|
|
|
|
|
|
|
public function save() {
|
|
|
|
if (!$this->getMailKey()) {
|
|
|
|
$this->setMailKey(Filesystem::readRandomCharacters(20));
|
|
|
|
}
|
|
|
|
return parent::save();
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 23:01:03 +01:00
|
|
|
}
|
|
|
|
|
2017-05-03 20:11:14 +02:00
|
|
|
public function getViewURI() {
|
|
|
|
return '/macro/view/'.$this->getID().'/';
|
|
|
|
}
|
|
|
|
|
2014-01-06 21:17:23 +01:00
|
|
|
|
|
|
|
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
|
|
|
|
|
|
|
|
2013-02-17 15:37:09 +01:00
|
|
|
public function getApplicationTransactionEditor() {
|
|
|
|
return new PhabricatorMacroEditor();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionObject() {
|
2014-04-18 01:03:24 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionTemplate() {
|
2013-02-17 15:37:09 +01:00
|
|
|
return new PhabricatorMacroTransaction();
|
|
|
|
}
|
|
|
|
|
2014-12-04 22:58:52 +01:00
|
|
|
public function willRenderTimeline(
|
|
|
|
PhabricatorApplicationTransactionView $timeline,
|
|
|
|
AphrontRequest $request) {
|
|
|
|
|
|
|
|
return $timeline;
|
|
|
|
}
|
|
|
|
|
2014-01-06 21:17:23 +01:00
|
|
|
|
|
|
|
/* -( PhabricatorSubscribableInterface )----------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
public function isAutomaticallySubscribed($phid) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-27 16:51:37 +02:00
|
|
|
/* -( PhabricatorTokenRecevierInterface )---------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
public function getUsersToNotifyOfTokenGiven() {
|
|
|
|
return array(
|
|
|
|
$this->getAuthorPHID(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-06 21:17:23 +01:00
|
|
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
|
|
|
|
|
|
|
|
Adding some filters and queries to Macro application
Summary:
Fixes T2778
Introduces `PhabricatorMacroQuery`, which should consolidate all queries regarding macros
Adds `PolicyInterface` to `PhabricatorImageMacro`, as else the query would fail (we should consider adding it to the ApplicationTransaction instead, if that was ever planned)
Adds `Active Macros` filter, making it the default
Adds `My Macros` filter. You may ask why it overwrites `$authors`. Well, I did not want the page jump to the conclusion that it is a search result. It //is// one more or less, but the filter would jump to `seach` instead of `my`. If you want `My Macros` removed, tell me. It is useful only to heavy-macro-uploaders-and-users though. Five or six people in `http://secure.phabricator.(org|com)`, and an estimated dozen and a half at bigger installs.
Test Plan: created multiple macros from multiple authors, disabled them at will. browsed around, verified that Macros only appeared in the right filters and that nothing else broke.
Reviewers: epriestley, chad, btrahan
CC: aran, Korvin
Maniphest Tasks: T2778
Differential Revision: https://secure.phabricator.com/D5409
2013-03-22 17:46:21 +01:00
|
|
|
public function getCapabilities() {
|
|
|
|
return array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
2017-05-03 20:11:14 +02:00
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
Adding some filters and queries to Macro application
Summary:
Fixes T2778
Introduces `PhabricatorMacroQuery`, which should consolidate all queries regarding macros
Adds `PolicyInterface` to `PhabricatorImageMacro`, as else the query would fail (we should consider adding it to the ApplicationTransaction instead, if that was ever planned)
Adds `Active Macros` filter, making it the default
Adds `My Macros` filter. You may ask why it overwrites `$authors`. Well, I did not want the page jump to the conclusion that it is a search result. It //is// one more or less, but the filter would jump to `seach` instead of `my`. If you want `My Macros` removed, tell me. It is useful only to heavy-macro-uploaders-and-users though. Five or six people in `http://secure.phabricator.(org|com)`, and an estimated dozen and a half at bigger installs.
Test Plan: created multiple macros from multiple authors, disabled them at will. browsed around, verified that Macros only appeared in the right filters and that nothing else broke.
Reviewers: epriestley, chad, btrahan
CC: aran, Korvin
Maniphest Tasks: T2778
Differential Revision: https://secure.phabricator.com/D5409
2013-03-22 17:46:21 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPolicy($capability) {
|
2017-05-03 20:11:14 +02:00
|
|
|
switch ($capability) {
|
|
|
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
|
|
|
return PhabricatorPolicies::getMostOpenPolicy();
|
|
|
|
case PhabricatorPolicyCapability::CAN_EDIT:
|
|
|
|
$app = PhabricatorApplication::getByClass(
|
|
|
|
'PhabricatorMacroApplication');
|
|
|
|
return $app->getPolicy(PhabricatorMacroManageCapability::CAPABILITY);
|
|
|
|
}
|
Adding some filters and queries to Macro application
Summary:
Fixes T2778
Introduces `PhabricatorMacroQuery`, which should consolidate all queries regarding macros
Adds `PolicyInterface` to `PhabricatorImageMacro`, as else the query would fail (we should consider adding it to the ApplicationTransaction instead, if that was ever planned)
Adds `Active Macros` filter, making it the default
Adds `My Macros` filter. You may ask why it overwrites `$authors`. Well, I did not want the page jump to the conclusion that it is a search result. It //is// one more or less, but the filter would jump to `seach` instead of `my`. If you want `My Macros` removed, tell me. It is useful only to heavy-macro-uploaders-and-users though. Five or six people in `http://secure.phabricator.(org|com)`, and an estimated dozen and a half at bigger installs.
Test Plan: created multiple macros from multiple authors, disabled them at will. browsed around, verified that Macros only appeared in the right filters and that nothing else broke.
Reviewers: epriestley, chad, btrahan
CC: aran, Korvin
Maniphest Tasks: T2778
Differential Revision: https://secure.phabricator.com/D5409
2013-03-22 17:46:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-04-14 00:15:48 +02:00
|
|
|
}
|