/**
  * Update the revision information of a cobrand  from the config.version table.
  *
  * @param array $cobrandid, $role
  * @return boolean
  */
 function UpdateRevision($cobrandid, $role)
 {
     $ret = false;
     if ($cobrandid && $role) {
         if ($this->GetRevision($cobrandid, $role, true)) {
             $query = DataManager::Query("db.config.version.{$cobrandid}.{$role}:nocache", "UPDATE config.version SET revision=revision+1, updated=now() WHERE cobrandid=:cobrandid and role=:role", array(":cobrandid" => $cobrandid, ":role" => $role));
             if (!empty($query) && $query->numrows > 0) {
                 $ret = true;
             }
         }
     }
     if ($ret) {
         DataManager::CacheClear("db.config.version.{$cobrandid}.{$role}");
         DataManager::CacheClear("db.config.version.ALL.{$role}");
     }
     return $ret;
 }
Example #2
0
 function controller_memcache(&$args, $output = "inline")
 {
     $vars["admin"] = false;
     $user = User::singleton();
     if ($user->isLoggedIn() && $user->HasRole("ADMIN")) {
         if (!empty($args["memcacheaction"])) {
             if ($args["memcacheaction"] == "delete" && !empty($args["memcachekey"])) {
                 DataManager::CacheClear($args["memcachekey"]);
                 $vars["tf_debug_memcache_status"] = "Deleted key '{$args['memcachekey']}'";
             } else {
                 if ($args["memcacheaction"] == "flush" && !empty($args["memcachetype"])) {
                     $data = DataManager::singleton();
                     if (!empty($data->caches["memcache"][$args["memcachetype"]])) {
                         if ($data->caches["memcache"][$args["memcachetype"]]->flush()) {
                             $vars["tf_debug_memcache_status"] = "Cache flushed successfully (" . $args["memcachetype"] . ")";
                         } else {
                             $vars["tf_debug_memcache_status"] = "FAILED TO FLUSH CACHE: " . $args["memcachetype"];
                         }
                     } else {
                         $vars["tf_debug_memcache_status"] = "ERROR: Unknown memcache type '" . $args["memcachetype"] . "'";
                     }
                 }
             }
         }
         $vars["admin"] = true;
     }
     if (!empty($data->caches["memcache"]["session"])) {
         $vars["stats"]["session"] = $data->caches["memcache"]["session"]->getExtendedStats();
     }
     if (!empty($data->caches["memcache"]["data"])) {
         $vars["stats"]["data"] = $data->caches["memcache"]["data"]->getExtendedStats();
     }
     if ($output == "ajax") {
         $vars = array("tf_debug_tab_memcache" => $this->GetTemplate("./memcache.tpl", $vars));
     }
     return $this->GetComponentResponse("./memcache.tpl", $vars);
 }
Example #3
0
 /**
  * This function perform an update query on a row in the specified table.
  *
  * @param string $id (resource id)
  * @param string $table
  * @param array $values
  * @param array $where_condition
  * @return int (last insert id)
  */
 static function &QueryUpdate($id, $table, $values, $where_condition = NULL, $bind_vars = array())
 {
     Profiler::StartTimer("DataManager::QueryUpdate()");
     Profiler::StartTimer("DataManager::QueryUpdate({$id})", 3);
     $qstart = microtime(true);
     $rows_affected = NULL;
     $queryid = new DatamanagerQueryID($id);
     if ($source =& DataManager::PickSource($queryid)) {
         $rows_affected = $source->QueryUpdate($queryid, $table, $values, $where_condition, $bind_vars);
         if ($rows_affected > 0) {
             DataManager::CacheClear($id);
         }
     }
     Profiler::StopTimer("DataManager::QueryUpdate()");
     Profiler::StopTimer("DataManager::QueryUpdate({$id})");
     self::log("update", $id, $table, $qstart, microtime(true));
     return $rows_affected;
 }