]> git.mxchange.org Git - friendica.git/blobdiff - mod/starred.php
Update Addon functions and calls
[friendica.git] / mod / starred.php
index 27f924e44b5452abad9c95ca3ec655019f83b23e..5cd9c0fe18768a2a9b9a701e0bf180c6ec1d0652 100644 (file)
@@ -1,30 +1,38 @@
 <?php
 
+use Friendica\App;
+use Friendica\Core\System;
+use Friendica\Database\DBM;
 
-function starred_init(&$a) {
+function starred_init(App $a) {
 
        require_once("include/threads.php");
 
        $starred = 0;
 
-       if(! local_user())
+       if (! local_user()) {
                killme();
-       if($a->argc > 1)
+       }
+       if ($a->argc > 1) {
                $message_id = intval($a->argv[1]);
-       if(! $message_id)
+       }
+       if (! $message_id) {
                killme();
+       }
 
-       $r = q("SELECT starred FROM item WHERE uid = %d AND id = %d LIMIT 1",
+       $r = q("SELECT `starred` FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
                intval(local_user()),
                intval($message_id)
        );
-       if(! dbm::is_result($r))
+       if (! DBM::is_result($r)) {
                killme();
+       }
 
-       if(! intval($r[0]['starred']))
+       if (! intval($r[0]['starred'])) {
                $starred = 1;
+       }
 
-       $r = q("UPDATE item SET starred = %d WHERE uid = %d and id = %d",
+       $r = q("UPDATE `item` SET `starred` = %d WHERE `uid` = %d AND `id` = %d",
                intval($starred),
                intval(local_user()),
                intval($message_id)
@@ -34,12 +42,15 @@ function starred_init(&$a) {
 
        // See if we've been passed a return path to redirect to
        $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
-       if($return_path) {
+       if ($return_path) {
                $rand = '_=' . time();
-               if(strpos($return_path, '?')) $rand = "&$rand";
-               else $rand = "?$rand";
+               if (strpos($return_path, '?')) {
+                       $rand = "&$rand";
+               } else {
+                       $rand = "?$rand";
+               }
 
-               goaway($a->get_baseurl() . "/" . $return_path . $rand);
+               goaway(System::baseUrl() . "/" . $return_path . $rand);
        }
 
        // the json doesn't really matter, it will either be 0 or 1