Esempio n. 1
0
 /**
  * @deprecated
  * Enter description here ...
  * @param unknown_type $type
  * @param unknown_type $id
  */
 static function getAccessCount($type, $id)
 {
     if ($type == null || $type == "" || $id == null) {
         return 0;
     }
     $db = new DBManager();
     if (!$db->connect_errno()) {
         define_tables();
         defineLogColumns();
         $table = Query::getDBSchema()->getTable("AccessLog");
         $exists = false;
         if ($type == "Post") {
             require_once 'post/PostManager.php';
             return 0;
             $exists = PostManager::postExists($id);
         } else {
             if ($type == "User") {
                 require_once 'user/UserManager.php';
                 return 0;
                 $exists = UserManager::userExists($id);
             } elseif ($type == "Partner") {
                 //TODO: implementa Partner
                 //				require_once 'post/PartnerManager.php';
                 //				$exists = PartnerManager::partnerExists($id);
             }
         }
         if ($exists) {
             $wheres = array(new WhereConstraint($table->getColumn("alog_type"), Operator::EQUAL, $type), new WhereConstraint($table->getColumn("alog_id"), Operator::EQUAL, $id));
             $db->execute($s = Query::generateSelectStm(array($table), array(), $wheres, array()));
             if ($db->num_rows() == 1) {
                 $row = $db->fetch_result();
                 $data = array("alog_count" => ++$row["alog_count"]);
                 $db->execute($s = Query::generateUpdateStm($table, $data, $wheres), null, LOGMANAGER);
                 if ($db->affected_rows() == 1) {
                     return $row["alog_count"];
                 }
             } else {
                 $data = array("alog_type" => $type, "alog_id" => $id);
                 $db->execute($s = Query::generateInsertStm($table, $data));
                 if ($db->affected_rows() == 1) {
                 }
                 return 1;
             }
         }
         return 0;
     }
 }