return null;
}
- static function saveNew($user, $address, $addressType, $extra=null)
+ static function saveNew(User $user, $address, $addressType, $extra=null)
{
$ca = new Confirm_address();
return $out_url;
}
- function saveNew($data, $file_id, $url) {
+ function saveNew(array $data, $file_id, $url) {
$file_redir = new File_redirection;
$file_redir->url = $url;
$file_redir->file_id = $file_id;
* @param int $file_id
*/
public static function saveNew($data, $file_id) {
+ // @TODO Must be an object (see below code)
+ assert(is_object($data));
+
if (!empty($data->thumbnail_url)) {
// Non-photo types such as video will usually
// show us a thumbnail, though it's not required.
* @return Notice
* @throws ClientException
*/
- static function saveNew($profile_id, $content, $source, array $options=null) {
+ static function saveNew($profile_id, $content, $source, array $options=array()) {
$defaults = array('uri' => null,
'url' => null,
'conversation' => null, // URI of conversation
'object_type' => null,
'verb' => null);
- if (!empty($options) && is_array($options)) {
+ /*
+ * Above type-hint is already array, so simply count it, this saves
+ * "some" CPU cycles.
+ */
+ if (count($options) > 0) {
$options = array_merge($defaults, $options);
- extract($options);
- } else {
- extract($defaults);
}
+ extract($options);
+
if (!isset($is_local)) {
$is_local = Notice::LOCAL_PUBLIC;
}
}
}
- function toHTML($args=null)
+ function toHTML(array $args=null)
{
if (is_null($args)) {
$args = array();
* 'location_id' ID of location
* 'location_ns' Namespace of location
*/
- function __construct($action, $options=null)
+ function __construct(Action $action, array $options = array())
{
// XXX: ??? Is this to keep notice forms distinct?
// Do we have to worry about sub-second race conditions?
parent::__construct($action);
- if (is_null($options)) {
- $options = array();
- }
-
$this->actionName = $action->trimmed('action');
$prefill = array('content', 'inreplyto', 'lat',
return true;
}
- function onNoticeDeleteRelated($notice) {
+ function onNoticeDeleteRelated(Notice $notice) {
$score = Spam_score::getKV('notice_id', $notice->id);
if (!empty($score)) {
$score->delete();
return true;
}
- function onUserRightsCheck($profile, $right, &$result) {
+ function onUserRightsCheck(Profile $profile, $right, &$result) {
switch ($right) {
case self::REVIEWSPAM:
case self::TRAINSPAM:
public $score; // float
public $created; // datetime
- function saveNew($notice, $result) {
+ function saveNew(Notice $notice, $result) {
$score = new Spam_score();
);
}
- static function saveNew($profile, $title, $content, $options=null)
+ static function saveNew(Profile $profile, $title, $content, array $options = array())
{
- if (is_null($options)) {
- $options = array();
- }
-
$be = new Blog_entry();
$be->id = (string) new UUID();
$be->profile_id = $profile->id;
}
}
- static function fromNotice($notice)
+ static function fromNotice(Notice $notice)
{
return Blog_entry::getKV('uri', $notice->uri);
}
*
* @return boolean hook value
*/
- function onUserRightsCheck($profile, $right, &$result)
+ function onUserRightsCheck(Profile $profile, $right, &$result)
{
if ($right == self::IMPORTDELICIOUS) {
$result = !$profile->isSilenced();
*
* @return Bookmark found bookmark or null
*/
- static function getByNotice($notice)
+ static function getByNotice(Notice $notice)
{
return self::getKV('uri', $notice->uri);
}
*
* @return Bookmark bookmark found or null
*/
- static function getByURL($profile, $url)
+ static function getByURL(Profile $profile, $url)
{
$nb = new Bookmark();
*
* @return Notice saved notice
*/
- static function saveNew($profile, $title, $url, $rawtags, $description,
- $options=null)
+ static function saveNew(Profile $profile, $title, $url, $rawtags, $description,
+ array $options=array())
{
if (!common_valid_http_url($url)) {
throw new ClientException(_m('Only web bookmarks can be posted (HTTP or HTTPS).'));
throw new ClientException(_m('Bookmark already exists.'));
}
- if (empty($options)) {
- $options = array();
- }
-
if (array_key_exists('uri', $options)) {
$other = Bookmark::getKV('uri', $options['uri']);
if (!empty($other)) {
);
}
- static function saveNew($profile, $start_time, $end_time, $title, $location, $description, $url, $options=array())
+ static function saveNew(Profile $profile, $start_time, $end_time, $title, $location, $description, $url, array $options=array())
{
if (array_key_exists('uri', $options)) {
$other = Happening::getKV('uri', $options['uri']);
return Notice::getKV('uri', $this->uri);
}
- static function fromNotice($notice)
+ static function fromNotice(Notice $notice)
{
return Happening::getKV('uri', $notice->uri);
}
);
}
- function saveNew($profile, $event, $verb, $options=array())
+ function saveNew(Profile $profile, $event, $verb, array $options = array())
{
if (array_key_exists('uri', $options)) {
$other = RSVP::getKV('uri', $options['uri']);
$this->response);
}
- static function toHTML($profile, $event, $response)
+ static function toHTML(Profile $profile, Event $event, $response)
{
$fmt = null;
public $description; // text
public $profile_id; // int
- public static function getByNotice($notice)
+ public static function getByNotice(Notice $notice)
{
return self::getKV('uri', $notice->uri);
}
);
}
- static function saveNew(Profile $profile, $photo_uri, $thumb_uri, $title, $description, $options=array())
+ static function saveNew(Profile $profile, $photo_uri, $thumb_uri, $title, $description, array $options=array())
{
$photo = new Photo();
public $url; // varchar (255)
public $profile_id; // int
- public static function getByNotice($notice)
+ public static function getByNotice(Notice $notice)
{
return self::getKV('uri', $notice->uri);
}
);
}
- static function saveNew(Profile $profile, $url, $options=array())
+ static function saveNew(Profile $profile, $url, array $options=array())
{
$vid = new Video();
return JSMin::minify($code);
}
- static function minifyCss($code, $options = array()) {
+ static function minifyCss($code, array $options = array()) {
require_once('Minify/CSS.php');
return Minify_CSS::minify($code,$options);
}
return true;
}
- function onUserRightsCheck($profile, $right, &$result)
+ function onUserRightsCheck(Profile $profile, $right, &$result)
{
if (in_array($right, self::$rights)) {
// Hrm.... really we should confirm that the *other* user isn't privleged. :)
return true;
}
- function onEndGrantRole($profile, $role)
+ function onEndGrantRole(Profile $profile, $role)
{
$modlog = new ModLog();
$modlog->profile_id = $profile->id;
$cur = common_current_user();
-
+
if (!empty($cur)) {
$modlog->moderator_id = $cur->id;
}
return true;
}
- function onEndRevokeRole($profile, $role)
+ function onEndRevokeRole(Profile $profile, $role)
{
$modlog = new ModLog();
$modlog->profile_id = $profile->id;
$cur = common_current_user();
-
+
if (!empty($cur)) {
$modlog->moderator_id = $cur->id;
}
}
}
- function onUserRightsCheck($profile, $right, &$result) {
+ function onUserRightsCheck(Profile $profile, $right, &$result) {
switch ($right) {
case self::VIEWMODLOG:
$result = ($profile->hasRole(Profile_role::MODERATOR) || $profile->hasRole('modhelper'));
*
* @return boolean hook value
*/
- function onNoticeDeleteRelated($notice)
+ function onNoticeDeleteRelated(Notice $notice)
{
$nt = Notice_title::getKV('notice_id', $notice->id);
*
* @return boolean hook value
*/
- function onStartShowHeadTitle($action)
+ function onStartShowHeadTitle(Action $action)
{
$actionName = $action->trimmed('action');
*
* @return string title of the notice, or null if none
*/
- static function fromNotice($notice)
+ static function fromNotice(Notice $notice)
{
$nt = Notice_title::getKV('notice_id', $notice->id);
if (empty($nt)) {
* @param int $file_id
*/
public static function saveNew($data, $file_id) {
+ // @TODO Must be an object
+ assert(is_object($data));
+
$file_oembed = new File_oembed;
$file_oembed->file_id = $file_id;
if (!isset($data->version)) {
*
* @return Poll found poll or null
*/
- static function getByNotice($notice)
+ static function getByNotice(Notice $notice)
{
return self::getKV('uri', $notice->uri);
}
*
* @return Notice saved notice
*/
- static function saveNew($profile, $question, $opts, $options=null)
+ static function saveNew(Profile $profile, $question, $opts, array $options = array())
{
- if (empty($options)) {
- $options = array();
- }
-
$p = new Poll();
$p->id = UUID::gen();
*
* @return Poll_response found response or null
*/
- static function getByNotice($notice)
+ static function getByNotice(Notice $notice)
{
return self::getKV('uri', $notice->uri);
}
*
* @return Notice saved notice
*/
- static function saveNew($profile, $poll, $selection, $options=null)
+ static function saveNew(Profile $profile, $poll, $selection, array $options=array)
{
- if (empty($options)) {
- $options = array();
- }
-
if (!$poll->isValidSelection($selection)) {
// TRANS: Client exception thrown when responding to a poll with an invalid option.
throw new ClientException(_m('Invalid poll selection.'));
*
* @return QnA_Answer found response or null
*/
- static function getByNotice($notice)
+ static function getByNotice(Notice $notice)
{
$answer = self::getKV('uri', $notice->uri);
if (empty($answer)) {
return Notice::getKV('uri', $this->uri);
}
- static function fromNotice($notice)
+ static function fromNotice(Notice $notice)
{
return QnA_Answer::getKV('uri', $notice->uri);
}
);
}
- static function toHTML($profile, $question, $answer)
+ static function toHTML(Profile $profile, $question, $answer)
{
$notice = $question->getNotice();
*
* @return Notice saved notice
*/
- static function saveNew($profile, $question, $text, $options = null)
+ static function saveNew(Profile $profile, $question, $text, array $options = array())
{
- if (empty($options)) {
- $options = array();
- }
-
$answer = new QnA_Answer();
$answer->id = UUID::gen();
$answer->profile_id = $profile->id;
*
* @return Question found question or null
*/
- static function getByNotice($notice)
+ static function getByNotice(Notice $notice)
{
return self::getKV('uri', $notice->uri);
}
return $a->count();
}
- static function fromNotice($notice)
+ static function fromNotice(Notice $notice)
{
return QnA_Question::getKV('uri', $notice->uri);
}
return self::toString($this->getProfile(), $this);
}
- static function toHTML($profile, $question)
+ static function toHTML(Profile $profile, $question)
{
$notice = $question->getNotice();
*
* @return Notice saved notice
*/
- static function saveNew($profile, $title, $description, $options = array())
+ static function saveNew(Profile $profile, $title, $description, array $options = array())
{
$q = new QnA_Question();
*
* @return void
*/
- function __construct($out = null, $title = null, $description = null, $options = null)
+ function __construct($out = null, $title = null, $description = null, array $options = array())
{
parent::__construct($out);
$this->title = $title;
return true;
}
- function onStartRegistrationTry($action)
+ /**
+ * Called when someone tries to register.
+ *
+ * We check the IP here to determine if it goes over any of our
+ * configured limits.
+ *
+ * @param Action $action Action that is being executed
+ *
+ * @return boolean hook value
+ */
+ function onStartRegistrationTry(Action $action)
{
$resp = recaptcha_check_answer ($this->private_key,
$_SERVER["REMOTE_ADDR"],
*
* @return boolean hook value
*/
- public function onStartRegistrationTry($action)
+ public function onStartRegistrationTry(Action $action)
{
$ipaddress = $this->_getIpAddress();
*
* @return boolean hook value
*/
- public function onEndGrantRole($profile, $role)
+ public function onEndGrantRole(Profile $profile, $role)
{
if (!self::$enabled) {
return true;
* Kind of dirty, but if pulling an external data feed into an account
* that may be what you want.
*
- * @param Notice $notice
- * @return mixed Notice on successful repeat, true if already repeated, false on failure
+ * @param Profile $profile
+ * @param Notice $notice
+ * @return mixed Notice on successful repeat, true if already repeated, false on failure
*/
- protected function copyNotice($profile, $notice)
+ protected function copyNotice(Profile $profile, Notice $notice)
{
$options = array('is_local' => Notice::LOCAL_PUBLIC,
'url' => $notice->getUrl(), // pass through the foreign link...
* @param boolean &$result out, result of the check
*
* @return boolean hook result
+ * @TODO Other implementing classes expect Profile here!!!
+ * @WARNING
*/
function onUserRightsCheck($user, $right, &$result)
{
return true;
}
- function onStartRegistrationTry($action)
+ /**
+ * Called when someone tries to register.
+ *
+ * We check the IP here to determine if it goes over any of our
+ * configured limits.
+ *
+ * @param Action $action Action that is being executed
+ *
+ * @return boolean hook value
+ */
+ function onStartRegistrationTry(Action $action)
{
$this->_checkMaxUsers();
return true;